mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-28 13:08:45 +02:00
N°8772 - Compiler: Add errors check
This commit is contained in:
@@ -16,13 +16,14 @@ use utils;
|
||||
*/
|
||||
abstract class AbstractProperty
|
||||
{
|
||||
protected ?AbstractProperty $oParent;
|
||||
protected string $sId;
|
||||
protected ?string $sLabel;
|
||||
|
||||
/** @var array<AbstractProperty> */
|
||||
protected array $aChildren = [];
|
||||
protected ?AbstractValueType $oValueType;
|
||||
protected ?string $sParentId;
|
||||
protected ?string $sIdWithPath;
|
||||
|
||||
/**
|
||||
* Init property tree node from xml dom node
|
||||
@@ -34,14 +35,15 @@ abstract class AbstractProperty
|
||||
* @throws \DOMFormatException
|
||||
* @throws \Combodo\iTop\PropertyTree\PropertyTreeException
|
||||
*/
|
||||
public function InitFromDomNode(DesignElement $oDomNode, string $sParentId = ''): void
|
||||
public function InitFromDomNode(DesignElement $oDomNode, ?AbstractProperty $oParent = null): void
|
||||
{
|
||||
if (utils::IsNotNullOrEmptyString($sParentId)) {
|
||||
$this->sId = $sParentId.'__';
|
||||
$this->oParent = $oParent;
|
||||
$this->sId = $oDomNode->getAttribute('id');
|
||||
if (is_null($oParent)) {
|
||||
$this->sIdWithPath = $this->sId;
|
||||
} else {
|
||||
$this->sId = '';
|
||||
$this->sIdWithPath = $oParent->sIdWithPath.'__'.$this->sId;
|
||||
}
|
||||
$this->sId .= $oDomNode->getAttribute('id');
|
||||
$this->sLabel = $oDomNode->GetChildText('label');
|
||||
}
|
||||
|
||||
@@ -61,4 +63,19 @@ abstract class AbstractProperty
|
||||
{
|
||||
return $this->aChildren;
|
||||
}
|
||||
|
||||
public function GetSibling(string $sId): ?AbstractProperty
|
||||
{
|
||||
if (is_null($this->oParent)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($this->oParent->GetChildren() as $oSibling) {
|
||||
if ($oSibling->sId == $sId) {
|
||||
return $oSibling;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user