mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-26 13:44:19 +01:00
65 lines
1.4 KiB
PHP
65 lines
1.4 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\AbstractValueType;
|
|
use utils;
|
|
|
|
/**
|
|
* @since 3.3.0
|
|
*/
|
|
abstract class AbstractProperty
|
|
{
|
|
protected string $sId;
|
|
protected ?string $sLabel;
|
|
|
|
/** @var array<AbstractProperty> */
|
|
protected array $aChildren = [];
|
|
protected ?AbstractValueType $oValueType;
|
|
protected ?string $sParentId;
|
|
|
|
/**
|
|
* Init property tree node from xml dom node
|
|
*
|
|
* @param \Combodo\iTop\DesignElement $oDomNode
|
|
* @param string $sParentId
|
|
*
|
|
* @return void
|
|
* @throws \DOMFormatException
|
|
* @throws \Combodo\iTop\PropertyTree\PropertyTreeException
|
|
*/
|
|
public function InitFromDomNode(DesignElement $oDomNode, string $sParentId = ''): void
|
|
{
|
|
if (utils::IsNotNullOrEmptyString($sParentId)) {
|
|
$this->sId = $sParentId.'__';
|
|
} else {
|
|
$this->sId = '';
|
|
}
|
|
$this->sId .= $oDomNode->getAttribute('id');
|
|
$this->sLabel = $oDomNode->GetChildText('label');
|
|
}
|
|
|
|
abstract public function ToPHPFormBlock(&$aPHPFragments = []): string;
|
|
|
|
public function GetValueType(): ?AbstractValueType
|
|
{
|
|
return $this->oValueType;
|
|
}
|
|
|
|
public function AddChild(AbstractProperty $oValueType): void
|
|
{
|
|
$this->aChildren[] = $oValueType;
|
|
}
|
|
|
|
public function GetChildren(): array
|
|
{
|
|
return $this->aChildren;
|
|
}
|
|
}
|