45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
namespace PSC\Library\Calc\Option\Parser;
|
|
|
|
class Base
|
|
{
|
|
/** @var \PSC\Library\Calc\Option\Type\Base $element */
|
|
protected $element;
|
|
|
|
/** @var \SimpleXMLElement $node */
|
|
protected $node;
|
|
|
|
public function __construct(\SimpleXMLElement $node)
|
|
{
|
|
$this->node = $node;
|
|
}
|
|
|
|
protected function parse()
|
|
{
|
|
$this->element->setId((string)$this->node['id']);
|
|
$this->element->setName((string)$this->node['name']);
|
|
|
|
if(isset($this->node['default'])) {
|
|
$this->element->setDefault((string)$this->node['default']);
|
|
}
|
|
if(isset($this->node['require'])) {
|
|
$this->element->setRequire($this->getBoolean($this->node['require']));
|
|
}
|
|
if(isset($this->node['help'])) {
|
|
$this->element->setHelp((string)$this->node['help']);
|
|
}
|
|
if(isset($this->node['exportAjax']) && (string)$this->node['exportAjax'] == 1) {
|
|
$this->element->setIsAjaxExport(true);
|
|
}
|
|
|
|
}
|
|
|
|
private function getBoolean($value)
|
|
{
|
|
if((string)$value == 'true' || (string)$value == '1') {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} |