mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-21 11:22:34 +09:00
Implement default extravar skin to replace hardcoded HTML in ExtraItem class
This commit is contained in:
parent
dd06193a1d
commit
31fa498b19
14 changed files with 604 additions and 590 deletions
66
modules/extravar/models/ValueCollection.php
Normal file
66
modules/extravar/models/ValueCollection.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Modules\Extravar\Models;
|
||||
|
||||
class ValueCollection
|
||||
{
|
||||
/**
|
||||
* Properties for compatibility with legacy ExtraVar class.
|
||||
*/
|
||||
public $module_srl;
|
||||
public $keys = [];
|
||||
|
||||
/**
|
||||
* This method only exists for compatibility with legacy ExtraVar class.
|
||||
* Normally, you should just call new ValueCollection($module_srl).
|
||||
*
|
||||
* @deprecated
|
||||
* @param int $module_srl
|
||||
* @return self
|
||||
*/
|
||||
public static function getInstance(int $module_srl): self
|
||||
{
|
||||
return new self($module_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $module_srl
|
||||
* @param array $keys
|
||||
*/
|
||||
public function __construct(int $module_srl, $keys = [])
|
||||
{
|
||||
$this->module_srl = $module_srl;
|
||||
$this->setExtraVarKeys($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of extra keys for this module.
|
||||
*
|
||||
* @param array $keys
|
||||
* @return void
|
||||
*/
|
||||
public function setExtraVarKeys($keys)
|
||||
{
|
||||
if (!is_array($keys) || !count($keys))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($keys as $val)
|
||||
{
|
||||
$this->keys[$val->idx] = new Value($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value ?? null, $val->eid, $val->parent_type ?? 'document');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtraVars(): array
|
||||
{
|
||||
return $this->keys;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue