diff --git a/bootstrap.inc.php b/bootstrap.inc.php index 2566d6ad1..69b121f09 100644 --- a/bootstrap.inc.php +++ b/bootstrap.inc.php @@ -42,6 +42,7 @@ define('ITOP_DEFAULT_ENV', 'production'); define('MAINTENANCE_MODE_FILE', APPROOT.'data/.maintenance'); define('READONLY_MODE_FILE', APPROOT.'data/.readonly'); +// TODO 3.3 To deprecate /** * Exclude the parent class from the list * diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index 9fe2da13c..10474ed16 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -863,6 +863,7 @@ Nous espérons que vous aimerez cette version autant que nous avons eu du plaisi 'UI:LinksWidget:Autocomplete+' => 'Tapez les 3 premiers caractères...', 'UI:Edit:SearchQuery' => 'Sélectionner une requête prédéfinie', 'UI:Edit:TestQuery' => 'Tester la requête', + 'UI:Edit:QueryBook' => 'Predefined query', 'UI:Combo:SelectValue' => '--- choisissez une valeur ---', 'UI:Label:SelectedObjects' => 'Objets sélectionnés: ', 'UI:Label:AvailableObjects' => 'Objets disponibles: ', diff --git a/sources/PropertyType/PropertyType.php b/sources/PropertyType/PropertyType.php index fffbb31a7..98ebfdcfb 100644 --- a/sources/PropertyType/PropertyType.php +++ b/sources/PropertyType/PropertyType.php @@ -9,6 +9,7 @@ namespace Combodo\iTop\PropertyType; use Combodo\iTop\DesignElement; use Combodo\iTop\PropertyType\ValueType\AbstractValueType; +use Combodo\iTop\PropertyType\ValueType\ValueTypeFactory; /** * A property type is a definition of properties (organized in tree) @@ -35,12 +36,11 @@ class PropertyType $oDefinitionNode = $oDomNode->GetUniqueElement('definition'); $sDefinitionNodeType = $oDefinitionNode->getAttribute('xsi:type'); - - if (!is_a($sDefinitionNodeType, AbstractValueType::class, true)) { + $this->oValueType = ValueTypeFactory::GetInstance()->CreateValueType($sDefinitionNodeType); + if (is_null($this->oValueType)) { throw new PropertyTypeException('Unsupported xsi:type '.json_encode($sDefinitionNodeType), $oDomNode); } - $this->oValueType = new $sDefinitionNodeType(); $this->oValueType->SetRootId($this->sId); $this->oValueType->InitFromDomNode($oDefinitionNode); } diff --git a/sources/PropertyType/ValueType/ValueTypeFactory.php b/sources/PropertyType/ValueType/ValueTypeFactory.php index 3d158f190..2014a9eca 100644 --- a/sources/PropertyType/ValueType/ValueTypeFactory.php +++ b/sources/PropertyType/ValueType/ValueTypeFactory.php @@ -32,6 +32,15 @@ class ValueTypeFactory return static::$oInstance; } + public function CreateValueType(string $sClass): ?AbstractValueType + { + if (!is_a($sClass, AbstractValueType::class, true)) { + return null; + } + + return new $sClass(); + } + /** * @param \Combodo\iTop\DesignElement $oDomNode * @param \Combodo\iTop\PropertyType\ValueType\AbstractValueType|null $oParent diff --git a/tests/php-unit-tests/unitary-tests/sources/Forms/Block/BlockTest.php b/tests/php-unit-tests/unitary-tests/sources/Forms/Block/BlockTest.php index 7ce1cf406..2ddb66bdb 100644 --- a/tests/php-unit-tests/unitary-tests/sources/Forms/Block/BlockTest.php +++ b/tests/php-unit-tests/unitary-tests/sources/Forms/Block/BlockTest.php @@ -7,6 +7,7 @@ namespace Combodo\iTop\Test\UnitTest\Sources\Forms\Block; +use Combodo\iTop\Application\Dashboard\FormBlock\DashletPropertiesFormBlock; use Combodo\iTop\Forms\Block\AbstractTypeFormBlock; use Combodo\iTop\Forms\Block\Base\CheckboxFormBlock; use Combodo\iTop\Forms\Block\Base\FormBlock; @@ -14,7 +15,6 @@ use Combodo\iTop\Forms\Block\Base\TextFormBlock; use Combodo\iTop\Forms\Block\FormBlockException; use Combodo\iTop\Forms\Block\IFormBlock; use Combodo\iTop\Forms\Forms; -use Combodo\iTop\ItopSdkFormDemonstrator\Form\Block\Dashboard\DashletPropertiesFormBlock; use Combodo\iTop\Service\InterfaceDiscovery\InterfaceDiscovery; use Combodo\iTop\Test\UnitTest\sources\Forms\AbstractFormsTest; use OutOfBoundsException;