mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-26 05:44:12 +01:00
48 lines
1.0 KiB
PHP
48 lines
1.0 KiB
PHP
<?php
|
|
|
|
/*
|
|
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
|
* @license http://opensource.org/licenses/AGPL-3.0
|
|
*/
|
|
|
|
namespace Combodo\iTop\PropertyTree;
|
|
|
|
use Combodo\iTop\DesignElement;
|
|
use Combodo\iTop\PropertyTree\ValueType\ValueTypeFactory;
|
|
|
|
/**
|
|
* @since 3.3.0
|
|
*/
|
|
class Property extends AbstractProperty
|
|
{
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function InitFromDomNode(DesignElement $oDomNode, string $sParentId = ''): void
|
|
{
|
|
parent::InitFromDomNode($oDomNode);
|
|
|
|
$oValueTypeNode = $oDomNode->GetOptionalElement('value-type');
|
|
if ($oValueTypeNode) {
|
|
$this->oValueType = ValueTypeFactory::GetInstance()->CreateValueTypeFromDomNode($oValueTypeNode);
|
|
}
|
|
}
|
|
|
|
public function ToPHPFormBlock(&$aPHPFragments = []): string
|
|
{
|
|
$sFormBlockClass = $this->oValueType->GetFormBlockClass();
|
|
|
|
$sInputs = '';
|
|
foreach ($this->oValueType->GetInputs() as $sInput => $sValue) {
|
|
$sInputs .= "\n ->SetInputValue('$sInput', '$sValue')";
|
|
}
|
|
|
|
return <<<PHP
|
|
\$this->Add('$this->sId', '$sFormBlockClass', [
|
|
'label' => '$this->sLabel',
|
|
]){$sInputs};
|
|
|
|
PHP;
|
|
}
|
|
}
|