mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
N°9066 - Split XML serializer into normalizer and encoder
This commit is contained in:
@@ -564,11 +564,13 @@ return array(
|
||||
'Combodo\\iTop\\PropertyType\\PropertyTypeFactory' => $baseDir . '/sources/PropertyType/PropertyTypeFactory.php',
|
||||
'Combodo\\iTop\\PropertyType\\PropertyTypeService' => $baseDir . '/sources/PropertyType/PropertyTypeService.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\SerializerException' => $baseDir . '/sources/PropertyType/Serializer/SerializerException.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLEncoder' => $baseDir . '/sources/PropertyType/Serializer/XMLEncoder.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\AbstractXMLFormat' => $baseDir . '/sources/PropertyType/Serializer/XMLFormat/AbstractXMLFormat.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\XMLFormatCSV' => $baseDir . '/sources/PropertyType/Serializer/XMLFormat/XMLFormatCSV.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\XMLFormatFactory' => $baseDir . '/sources/PropertyType/Serializer/XMLFormat/XMLFormatFactory.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\XMLFormatFlatArray' => $baseDir . '/sources/PropertyType/Serializer/XMLFormat/XMLFormatFlatArray.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\XMLFormatValueAsId' => $baseDir . '/sources/PropertyType/Serializer/XMLFormat/XMLFormatValueAsId.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLNormalizer' => $baseDir . '/sources/PropertyType/Serializer/XMLNormalizer.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLSerializer' => $baseDir . '/sources/PropertyType/Serializer/XMLSerializer.php',
|
||||
'Combodo\\iTop\\PropertyType\\ValueType\\AbstractValueType' => $baseDir . '/sources/PropertyType/ValueType/AbstractValueType.php',
|
||||
'Combodo\\iTop\\PropertyType\\ValueType\\Branch\\AbstractBranchValueType' => $baseDir . '/sources/PropertyType/ValueType/Branch/AbstractBranchValueType.php',
|
||||
|
||||
@@ -28,12 +28,12 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f
|
||||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'T' =>
|
||||
'T' =>
|
||||
array (
|
||||
'Twig\\' => 5,
|
||||
'TheNetworg\\OAuth2\\Client\\' => 25,
|
||||
),
|
||||
'S' =>
|
||||
'S' =>
|
||||
array (
|
||||
'Symfony\\Polyfill\\Php83\\' => 23,
|
||||
'Symfony\\Polyfill\\Mbstring\\' => 26,
|
||||
@@ -82,7 +82,7 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f
|
||||
'ScssPhp\\ScssPhp\\' => 16,
|
||||
'Sabberworm\\CSS\\' => 15,
|
||||
),
|
||||
'P' =>
|
||||
'P' =>
|
||||
array (
|
||||
'Psr\\Log\\' => 8,
|
||||
'Psr\\Http\\Message\\' => 17,
|
||||
@@ -93,298 +93,298 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f
|
||||
'PhpParser\\' => 10,
|
||||
'Pelago\\Emogrifier\\' => 18,
|
||||
),
|
||||
'L' =>
|
||||
'L' =>
|
||||
array (
|
||||
'League\\OAuth2\\Client\\' => 21,
|
||||
),
|
||||
'G' =>
|
||||
'G' =>
|
||||
array (
|
||||
'GuzzleHttp\\Psr7\\' => 16,
|
||||
'GuzzleHttp\\Promise\\' => 19,
|
||||
'GuzzleHttp\\' => 11,
|
||||
),
|
||||
'F' =>
|
||||
'F' =>
|
||||
array (
|
||||
'Firebase\\JWT\\' => 13,
|
||||
),
|
||||
'E' =>
|
||||
'E' =>
|
||||
array (
|
||||
'Egulias\\EmailValidator\\' => 23,
|
||||
),
|
||||
'D' =>
|
||||
'D' =>
|
||||
array (
|
||||
'Doctrine\\Common\\Lexer\\' => 22,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'Twig\\' =>
|
||||
'Twig\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/twig/twig/src',
|
||||
),
|
||||
'TheNetworg\\OAuth2\\Client\\' =>
|
||||
'TheNetworg\\OAuth2\\Client\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/thenetworg/oauth2-azure/src',
|
||||
),
|
||||
'Symfony\\Polyfill\\Php83\\' =>
|
||||
'Symfony\\Polyfill\\Php83\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-php83',
|
||||
),
|
||||
'Symfony\\Polyfill\\Mbstring\\' =>
|
||||
'Symfony\\Polyfill\\Mbstring\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
|
||||
),
|
||||
'Symfony\\Polyfill\\Intl\\Normalizer\\' =>
|
||||
'Symfony\\Polyfill\\Intl\\Normalizer\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer',
|
||||
),
|
||||
'Symfony\\Polyfill\\Intl\\Idn\\' =>
|
||||
'Symfony\\Polyfill\\Intl\\Idn\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-intl-idn',
|
||||
),
|
||||
'Symfony\\Polyfill\\Intl\\Icu\\' =>
|
||||
'Symfony\\Polyfill\\Intl\\Icu\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-intl-icu',
|
||||
),
|
||||
'Symfony\\Polyfill\\Intl\\Grapheme\\' =>
|
||||
'Symfony\\Polyfill\\Intl\\Grapheme\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme',
|
||||
),
|
||||
'Symfony\\Polyfill\\Ctype\\' =>
|
||||
'Symfony\\Polyfill\\Ctype\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
|
||||
),
|
||||
'Symfony\\Contracts\\Translation\\' =>
|
||||
'Symfony\\Contracts\\Translation\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/translation-contracts',
|
||||
),
|
||||
'Symfony\\Contracts\\Service\\' =>
|
||||
'Symfony\\Contracts\\Service\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/service-contracts',
|
||||
),
|
||||
'Symfony\\Contracts\\EventDispatcher\\' =>
|
||||
'Symfony\\Contracts\\EventDispatcher\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/event-dispatcher-contracts',
|
||||
),
|
||||
'Symfony\\Contracts\\Cache\\' =>
|
||||
'Symfony\\Contracts\\Cache\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/cache-contracts',
|
||||
),
|
||||
'Symfony\\Component\\Yaml\\' =>
|
||||
'Symfony\\Component\\Yaml\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/yaml',
|
||||
),
|
||||
'Symfony\\Component\\VarExporter\\' =>
|
||||
'Symfony\\Component\\VarExporter\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/var-exporter',
|
||||
),
|
||||
'Symfony\\Component\\VarDumper\\' =>
|
||||
'Symfony\\Component\\VarDumper\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/var-dumper',
|
||||
),
|
||||
'Symfony\\Component\\Validator\\' =>
|
||||
'Symfony\\Component\\Validator\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/validator',
|
||||
),
|
||||
'Symfony\\Component\\String\\' =>
|
||||
'Symfony\\Component\\String\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/string',
|
||||
),
|
||||
'Symfony\\Component\\Stopwatch\\' =>
|
||||
'Symfony\\Component\\Stopwatch\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/stopwatch',
|
||||
),
|
||||
'Symfony\\Component\\Security\\Csrf\\' =>
|
||||
'Symfony\\Component\\Security\\Csrf\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/security-csrf',
|
||||
),
|
||||
'Symfony\\Component\\Security\\Core\\' =>
|
||||
'Symfony\\Component\\Security\\Core\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/security-core',
|
||||
),
|
||||
'Symfony\\Component\\Routing\\' =>
|
||||
'Symfony\\Component\\Routing\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/routing',
|
||||
),
|
||||
'Symfony\\Component\\PropertyInfo\\' =>
|
||||
'Symfony\\Component\\PropertyInfo\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/property-info',
|
||||
),
|
||||
'Symfony\\Component\\PropertyAccess\\' =>
|
||||
'Symfony\\Component\\PropertyAccess\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/property-access',
|
||||
),
|
||||
'Symfony\\Component\\PasswordHasher\\' =>
|
||||
'Symfony\\Component\\PasswordHasher\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/password-hasher',
|
||||
),
|
||||
'Symfony\\Component\\OptionsResolver\\' =>
|
||||
'Symfony\\Component\\OptionsResolver\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/options-resolver',
|
||||
),
|
||||
'Symfony\\Component\\Mime\\' =>
|
||||
'Symfony\\Component\\Mime\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/mime',
|
||||
),
|
||||
'Symfony\\Component\\Mailer\\' =>
|
||||
'Symfony\\Component\\Mailer\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/mailer',
|
||||
),
|
||||
'Symfony\\Component\\HttpKernel\\' =>
|
||||
'Symfony\\Component\\HttpKernel\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/http-kernel',
|
||||
),
|
||||
'Symfony\\Component\\HttpFoundation\\' =>
|
||||
'Symfony\\Component\\HttpFoundation\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/http-foundation',
|
||||
),
|
||||
'Symfony\\Component\\Form\\' =>
|
||||
'Symfony\\Component\\Form\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/form',
|
||||
),
|
||||
'Symfony\\Component\\Finder\\' =>
|
||||
'Symfony\\Component\\Finder\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/finder',
|
||||
),
|
||||
'Symfony\\Component\\Filesystem\\' =>
|
||||
'Symfony\\Component\\Filesystem\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/filesystem',
|
||||
),
|
||||
'Symfony\\Component\\EventDispatcher\\' =>
|
||||
'Symfony\\Component\\EventDispatcher\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/event-dispatcher',
|
||||
),
|
||||
'Symfony\\Component\\ErrorHandler\\' =>
|
||||
'Symfony\\Component\\ErrorHandler\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/error-handler',
|
||||
),
|
||||
'Symfony\\Component\\Dotenv\\' =>
|
||||
'Symfony\\Component\\Dotenv\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/dotenv',
|
||||
),
|
||||
'Symfony\\Component\\DependencyInjection\\' =>
|
||||
'Symfony\\Component\\DependencyInjection\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/dependency-injection',
|
||||
),
|
||||
'Symfony\\Component\\CssSelector\\' =>
|
||||
'Symfony\\Component\\CssSelector\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/css-selector',
|
||||
),
|
||||
'Symfony\\Component\\Console\\' =>
|
||||
'Symfony\\Component\\Console\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/console',
|
||||
),
|
||||
'Symfony\\Component\\Config\\' =>
|
||||
'Symfony\\Component\\Config\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/config',
|
||||
),
|
||||
'Symfony\\Component\\Cache\\' =>
|
||||
'Symfony\\Component\\Cache\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/cache',
|
||||
),
|
||||
'Symfony\\Bundle\\WebProfilerBundle\\' =>
|
||||
'Symfony\\Bundle\\WebProfilerBundle\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/web-profiler-bundle',
|
||||
),
|
||||
'Symfony\\Bundle\\TwigBundle\\' =>
|
||||
'Symfony\\Bundle\\TwigBundle\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/twig-bundle',
|
||||
),
|
||||
'Symfony\\Bundle\\FrameworkBundle\\' =>
|
||||
'Symfony\\Bundle\\FrameworkBundle\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/framework-bundle',
|
||||
),
|
||||
'Symfony\\Bridge\\Twig\\' =>
|
||||
'Symfony\\Bridge\\Twig\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/twig-bridge',
|
||||
),
|
||||
'Soundasleep\\' =>
|
||||
'Soundasleep\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/soundasleep/html2text/src',
|
||||
),
|
||||
'ScssPhp\\ScssPhp\\' =>
|
||||
'ScssPhp\\ScssPhp\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/scssphp/scssphp/src',
|
||||
),
|
||||
'Sabberworm\\CSS\\' =>
|
||||
'Sabberworm\\CSS\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/sabberworm/php-css-parser/src',
|
||||
),
|
||||
'Psr\\Log\\' =>
|
||||
'Psr\\Log\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/log/src',
|
||||
),
|
||||
'Psr\\Http\\Message\\' =>
|
||||
'Psr\\Http\\Message\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/http-factory/src',
|
||||
1 => __DIR__ . '/..' . '/psr/http-message/src',
|
||||
),
|
||||
'Psr\\Http\\Client\\' =>
|
||||
'Psr\\Http\\Client\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/http-client/src',
|
||||
),
|
||||
'Psr\\EventDispatcher\\' =>
|
||||
'Psr\\EventDispatcher\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/event-dispatcher/src',
|
||||
),
|
||||
'Psr\\Container\\' =>
|
||||
'Psr\\Container\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/container/src',
|
||||
),
|
||||
'Psr\\Cache\\' =>
|
||||
'Psr\\Cache\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/cache/src',
|
||||
),
|
||||
'PhpParser\\' =>
|
||||
'PhpParser\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser',
|
||||
),
|
||||
'Pelago\\Emogrifier\\' =>
|
||||
'Pelago\\Emogrifier\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/pelago/emogrifier/src',
|
||||
),
|
||||
'League\\OAuth2\\Client\\' =>
|
||||
'League\\OAuth2\\Client\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/league/oauth2-google/src',
|
||||
1 => __DIR__ . '/..' . '/league/oauth2-client/src',
|
||||
),
|
||||
'GuzzleHttp\\Psr7\\' =>
|
||||
'GuzzleHttp\\Psr7\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
|
||||
),
|
||||
'GuzzleHttp\\Promise\\' =>
|
||||
'GuzzleHttp\\Promise\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
|
||||
),
|
||||
'GuzzleHttp\\' =>
|
||||
'GuzzleHttp\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
|
||||
),
|
||||
'Firebase\\JWT\\' =>
|
||||
'Firebase\\JWT\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/firebase/php-jwt/src',
|
||||
),
|
||||
'Egulias\\EmailValidator\\' =>
|
||||
'Egulias\\EmailValidator\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/egulias/email-validator/src',
|
||||
),
|
||||
'Doctrine\\Common\\Lexer\\' =>
|
||||
'Doctrine\\Common\\Lexer\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/doctrine/lexer/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixesPsr0 = array (
|
||||
'C' =>
|
||||
'C' =>
|
||||
array (
|
||||
'Console' =>
|
||||
'Console' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/pear/console_getopt',
|
||||
),
|
||||
),
|
||||
'A' =>
|
||||
'A' =>
|
||||
array (
|
||||
'Archive_Tar' =>
|
||||
'Archive_Tar' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/pear/archive_tar',
|
||||
),
|
||||
@@ -950,11 +950,13 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f
|
||||
'Combodo\\iTop\\PropertyType\\PropertyTypeFactory' => __DIR__ . '/../..' . '/sources/PropertyType/PropertyTypeFactory.php',
|
||||
'Combodo\\iTop\\PropertyType\\PropertyTypeService' => __DIR__ . '/../..' . '/sources/PropertyType/PropertyTypeService.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\SerializerException' => __DIR__ . '/../..' . '/sources/PropertyType/Serializer/SerializerException.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLEncoder' => __DIR__ . '/../..' . '/sources/PropertyType/Serializer/XMLEncoder.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\AbstractXMLFormat' => __DIR__ . '/../..' . '/sources/PropertyType/Serializer/XMLFormat/AbstractXMLFormat.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\XMLFormatCSV' => __DIR__ . '/../..' . '/sources/PropertyType/Serializer/XMLFormat/XMLFormatCSV.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\XMLFormatFactory' => __DIR__ . '/../..' . '/sources/PropertyType/Serializer/XMLFormat/XMLFormatFactory.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\XMLFormatFlatArray' => __DIR__ . '/../..' . '/sources/PropertyType/Serializer/XMLFormat/XMLFormatFlatArray.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLFormat\\XMLFormatValueAsId' => __DIR__ . '/../..' . '/sources/PropertyType/Serializer/XMLFormat/XMLFormatValueAsId.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLNormalizer' => __DIR__ . '/../..' . '/sources/PropertyType/Serializer/XMLNormalizer.php',
|
||||
'Combodo\\iTop\\PropertyType\\Serializer\\XMLSerializer' => __DIR__ . '/../..' . '/sources/PropertyType/Serializer/XMLSerializer.php',
|
||||
'Combodo\\iTop\\PropertyType\\ValueType\\AbstractValueType' => __DIR__ . '/../..' . '/sources/PropertyType/ValueType/AbstractValueType.php',
|
||||
'Combodo\\iTop\\PropertyType\\ValueType\\Branch\\AbstractBranchValueType' => __DIR__ . '/../..' . '/sources/PropertyType/ValueType/Branch/AbstractBranchValueType.php',
|
||||
|
||||
@@ -79,4 +79,25 @@ PHP;
|
||||
{
|
||||
return $this->oValueType->UnserializeFromDOMNode($oDOMNode);
|
||||
}
|
||||
|
||||
public function Normalize(mixed $value): mixed
|
||||
{
|
||||
return $this->oValueType->Normalize($value);
|
||||
}
|
||||
|
||||
public function EncodeToDOMNode(mixed $normalizedValue, DesignElement $oDOMNode): void
|
||||
{
|
||||
$this->oValueType->EncodeToDOMNode($normalizedValue, $oDOMNode);
|
||||
}
|
||||
|
||||
public function DecodeFromDomNode(DesignElement $oDOMNode): mixed
|
||||
{
|
||||
return $this->oValueType->DecodeFromDomNode($oDOMNode);
|
||||
}
|
||||
|
||||
public function Denormalize(mixed $normalizedValue): mixed
|
||||
{
|
||||
return $this->oValueType->Denormalize($normalizedValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
58
sources/PropertyType/Serializer/XMLEncoder.php
Normal file
58
sources/PropertyType/Serializer/XMLEncoder.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2026 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\PropertyType\Serializer;
|
||||
|
||||
use Combodo\iTop\DesignElement;
|
||||
use Combodo\iTop\PropertyType\Compiler\PropertyTypeCompiler;
|
||||
|
||||
class XMLEncoder
|
||||
{
|
||||
private static XMLEncoder $oInstance;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
final public static function GetInstance(): XMLEncoder
|
||||
{
|
||||
if (!isset(static::$oInstance)) {
|
||||
static::$oInstance = new XMLEncoder();
|
||||
}
|
||||
|
||||
return static::$oInstance;
|
||||
}
|
||||
|
||||
public function Encode(mixed $normalizedValue, DesignElement $oParentNode, string $sId, string $sType): void
|
||||
{
|
||||
$sPropertyTypeXML = PropertyTypeCompiler::GetInstance()->GetXMLContent($sId, $sType);
|
||||
|
||||
$this->EncodeForPropertyType($normalizedValue, $oParentNode, $sPropertyTypeXML);
|
||||
}
|
||||
|
||||
public function Decode(DesignElement $oDOMNode, string $sId, string $sType): mixed
|
||||
{
|
||||
$sPropertyTypeXML = PropertyTypeCompiler::GetInstance()->GetXMLContent($sId, $sType);
|
||||
|
||||
return $this->DecodeForPropertyType($oDOMNode, $sPropertyTypeXML);
|
||||
}
|
||||
|
||||
public function EncodeForPropertyType(mixed $normalizedValue, DesignElement $oParentNode, string $sPropertyTypeXML): void
|
||||
{
|
||||
$oPropertyType = PropertyTypeCompiler::GetInstance()->CompilePropertyTypeFromXML($sPropertyTypeXML);
|
||||
|
||||
$oPropertyType->EncodeToDOMNode($normalizedValue, $oParentNode);
|
||||
}
|
||||
|
||||
public function DecodeForPropertyType(DesignElement $oParentNode, string $sPropertyTypeXML): mixed
|
||||
{
|
||||
$oPropertyType = PropertyTypeCompiler::GetInstance()->CompilePropertyTypeFromXML($sPropertyTypeXML);
|
||||
|
||||
return $oPropertyType->DecodeFromDomNode($oParentNode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,11 @@ abstract class AbstractXMLFormat
|
||||
{
|
||||
}
|
||||
|
||||
abstract public function SerializeToDOMNode(mixed $value, DesignElement $oDOMNode, AbstractValueType $oValueType): void;
|
||||
abstract public function Normalize($value, AbstractValueType $oValueType): mixed;
|
||||
|
||||
abstract public function UnserializeFromDOMNode(DesignElement $oDOMNode, AbstractValueType $oValueType): mixed;
|
||||
abstract public function EncodeToDOMNode(mixed $normalizedValue, DesignElement $oDOMNode, AbstractValueType $oValueType): void;
|
||||
|
||||
abstract public function DecodeFromDOMNode(DesignElement $oDOMNode, AbstractValueType $oValueType): mixed;
|
||||
|
||||
abstract public function Denormalize($normalizedValue, AbstractValueType $oValueType): mixed;
|
||||
}
|
||||
|
||||
@@ -12,16 +12,24 @@ use Combodo\iTop\PropertyType\ValueType\AbstractValueType;
|
||||
|
||||
class XMLFormatCSV extends AbstractXMLFormat
|
||||
{
|
||||
public function SerializeToDOMNode($value, $oDOMNode, AbstractValueType $oValueType): void
|
||||
public function EncodeToDOMNode(mixed $value, DesignElement $oDOMNode, AbstractValueType $oValueType): void
|
||||
{
|
||||
$sXmlValue = implode(',', $value);
|
||||
$oTextNode = $oDOMNode->ownerDocument->createTextNode($sXmlValue);
|
||||
$oTextNode = $oDOMNode->ownerDocument->createTextNode($value);
|
||||
$oDOMNode->appendChild($oTextNode);
|
||||
}
|
||||
|
||||
public function UnserializeFromDOMNode(DesignElement $oDOMNode, AbstractValueType $oValueType): mixed
|
||||
public function DecodeFromDOMNode(DesignElement $oDOMNode, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
$sValue = $oDOMNode->GetText('');
|
||||
return explode(',', $sValue);
|
||||
return $oDOMNode->GetText('');
|
||||
}
|
||||
|
||||
public function Normalize($value, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
return implode(',', $value);
|
||||
}
|
||||
|
||||
public function Denormalize($normalizedValue, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
return explode(',', $normalizedValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,27 +33,6 @@ class XMLFormatFlatArray extends AbstractXMLFormat
|
||||
$this->sCountTag = $sCountTag;
|
||||
}
|
||||
|
||||
public function SerializeToDOMNode($value, $oDOMNode, AbstractValueType $oValueType): void
|
||||
{
|
||||
if (!$oValueType instanceof ValueTypeCollection) {
|
||||
throw new SerializerException('XMLFormatFlatArray is allowed only in ValueTypeCollection nodes');
|
||||
}
|
||||
|
||||
$oCountNode = $oDOMNode->ownerDocument->createElement($this->sCountTag, count($value));
|
||||
$oDOMNode->appendChild($oCountNode);
|
||||
foreach ($value as $iRank => $aValues) {
|
||||
foreach ($oValueType->GetChildren() as $oChild) {
|
||||
$sId = $oChild->GetId();
|
||||
if (isset($aValues[$sId])) {
|
||||
$sTagName = \MetaModel::ApplyParams($this->sTagFormat, ['rank' => $iRank, 'id' => $sId]);
|
||||
$oChildNode = $oDOMNode->ownerDocument->createElement($sTagName);
|
||||
$oDOMNode->appendChild($oChildNode);
|
||||
$oChild->SerializeToDOMNode($aValues[$sId], $oChildNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function UnserializeFromDOMNode(DesignElement $oDOMNode, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
$aResults = [];
|
||||
@@ -76,4 +55,85 @@ class XMLFormatFlatArray extends AbstractXMLFormat
|
||||
|
||||
return $aResults;
|
||||
}
|
||||
|
||||
public function Normalize($value, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
if (!$oValueType instanceof ValueTypeCollection) {
|
||||
throw new SerializerException('XMLFormatFlatArray is allowed only in ValueTypeCollection nodes');
|
||||
}
|
||||
|
||||
$aNormalizedValues = [];
|
||||
$aNormalizedValues[$this->sCountTag] = count($value);
|
||||
|
||||
foreach ($value as $iRank => $aValues) {
|
||||
foreach ($oValueType->GetChildren() as $oChild) {
|
||||
$sId = $oChild->GetId();
|
||||
if (isset($aValues[$sId])) {
|
||||
$sTagName = \MetaModel::ApplyParams($this->sTagFormat, ['rank' => $iRank, 'id' => $sId]);
|
||||
$aNormalizedValues[$sTagName] = $oChild->Normalize($aValues[$sId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $aNormalizedValues;
|
||||
}
|
||||
|
||||
public function EncodeToDOMNode(mixed $normalizedValue, DesignElement $oDOMNode, AbstractValueType $oValueType): void
|
||||
{
|
||||
if (!$oValueType instanceof ValueTypeCollection) {
|
||||
throw new SerializerException('XMLFormatFlatArray is allowed only in ValueTypeCollection nodes');
|
||||
}
|
||||
|
||||
foreach ($normalizedValue as $sTag => $value) {
|
||||
$oNode = $oDOMNode->ownerDocument->createElement($sTag, $value);
|
||||
$oDOMNode->appendChild($oNode);
|
||||
}
|
||||
}
|
||||
|
||||
public function DecodeFromDOMNode(DesignElement $oDOMNode, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
if (!$oValueType instanceof ValueTypeCollection) {
|
||||
throw new SerializerException('XMLFormatFlatArray is allowed only in ValueTypeCollection nodes');
|
||||
}
|
||||
|
||||
$aNormalizedValues = [];
|
||||
|
||||
$iCount = $oDOMNode->GetUniqueElement($this->sCountTag)->GetText(0);
|
||||
$aNormalizedValues[$this->sCountTag] = $iCount;
|
||||
|
||||
for ($iRank = 0; $iRank < $iCount; $iRank++) {
|
||||
foreach ($oValueType->GetChildren() as $oChild) {
|
||||
$sId = $oChild->GetId();
|
||||
$sTagName = \MetaModel::ApplyParams($this->sTagFormat, ['rank' => $iRank, 'id' => $sId]);
|
||||
$oChildNode = $oDOMNode->GetOptionalElement($sTagName);
|
||||
if ($oChildNode) {
|
||||
$aNormalizedValues[$sTagName] = $oChildNode->GetText('');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $aNormalizedValues;
|
||||
}
|
||||
|
||||
public function Denormalize($normalizedValue, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
if (!$oValueType instanceof ValueTypeCollection) {
|
||||
throw new SerializerException('XMLFormatFlatArray is allowed only in ValueTypeCollection nodes');
|
||||
}
|
||||
|
||||
$aValues = [];
|
||||
|
||||
$iCount = $normalizedValue[$this->sCountTag];
|
||||
for ($iRank = 0; $iRank < $iCount; $iRank++) {
|
||||
foreach ($oValueType->GetChildren() as $oChild) {
|
||||
$sId = $oChild->GetId();
|
||||
$sTagName = \MetaModel::ApplyParams($this->sTagFormat, ['rank' => $iRank, 'id' => $sId]);
|
||||
if (isset($normalizedValue[$sTagName])) {
|
||||
$aValues[$iRank][$sId] = $normalizedValue[$sTagName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $aValues;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,35 @@ class XMLFormatValueAsId extends AbstractXMLFormat
|
||||
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
public function Normalize($value, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function EncodeToDOMNode(mixed $normalizedValue, DesignElement $oDOMNode, AbstractValueType $oValueType): void
|
||||
{
|
||||
foreach ($normalizedValue as $item) {
|
||||
$oChildNode = $oDOMNode->ownerDocument->createElement($this->sTagName);
|
||||
$oChildNode->setAttribute('id', "$item");
|
||||
$oDOMNode->appendChild($oChildNode);
|
||||
}
|
||||
}
|
||||
|
||||
public function DecodeFromDOMNode(DesignElement $oDOMNode, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
$aResult = [];
|
||||
|
||||
foreach ($oDOMNode->getElementsByTagName($this->sTagName) as $oNode) {
|
||||
$sValue = $oNode->getAttribute('id');
|
||||
$aResult[] = $sValue;
|
||||
}
|
||||
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
public function Denormalize($normalizedValue, AbstractValueType $oValueType): mixed
|
||||
{
|
||||
return $normalizedValue;
|
||||
}
|
||||
}
|
||||
|
||||
58
sources/PropertyType/Serializer/XMLNormalizer.php
Normal file
58
sources/PropertyType/Serializer/XMLNormalizer.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2026 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\PropertyType\Serializer;
|
||||
|
||||
use Combodo\iTop\DesignElement;
|
||||
use Combodo\iTop\PropertyType\Compiler\PropertyTypeCompiler;
|
||||
|
||||
class XMLNormalizer
|
||||
{
|
||||
private static XMLNormalizer $oInstance;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
final public static function GetInstance(): XMLNormalizer
|
||||
{
|
||||
if (!isset(static::$oInstance)) {
|
||||
static::$oInstance = new XMLNormalizer();
|
||||
}
|
||||
|
||||
return static::$oInstance;
|
||||
}
|
||||
|
||||
public function Normalize(mixed $value, string $sId, string $sType): mixed
|
||||
{
|
||||
$sPropertyTypeXML = PropertyTypeCompiler::GetInstance()->GetXMLContent($sId, $sType);
|
||||
|
||||
return $this->NormalizeForPropertyType($value, $sPropertyTypeXML);
|
||||
}
|
||||
|
||||
public function Denormalize(mixed $normalizedValue, string $sId, string $sType): mixed
|
||||
{
|
||||
$sPropertyTypeXML = PropertyTypeCompiler::GetInstance()->GetXMLContent($sId, $sType);
|
||||
|
||||
return $this->DenormalizeForPropertyType($normalizedValue, $sPropertyTypeXML);
|
||||
}
|
||||
|
||||
public function NormalizeForPropertyType(mixed $normalizedValue, string $sPropertyTypeXML): mixed
|
||||
{
|
||||
$oPropertyType = PropertyTypeCompiler::GetInstance()->CompilePropertyTypeFromXML($sPropertyTypeXML);
|
||||
|
||||
return $oPropertyType->Normalize($normalizedValue);
|
||||
}
|
||||
|
||||
public function DenormalizeForPropertyType(mixed $normalizedValue, string $sPropertyTypeXML): mixed
|
||||
{
|
||||
$oPropertyType = PropertyTypeCompiler::GetInstance()->CompilePropertyTypeFromXML($sPropertyTypeXML);
|
||||
|
||||
return $oPropertyType->Denormalize($normalizedValue);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,15 +45,15 @@ class XMLSerializer
|
||||
|
||||
public function SerializeForPropertyType(mixed $value, DesignElement $oParentNode, string $sPropertyTypeXML): void
|
||||
{
|
||||
$oPropertyType = PropertyTypeCompiler::GetInstance()->CompilePropertyTypeFromXML($sPropertyTypeXML);
|
||||
$normalizedValue = XMLNormalizer::GetInstance()->NormalizeForPropertyType($value, $sPropertyTypeXML);
|
||||
|
||||
$oPropertyType->SerializeToDOMNode($value, $oParentNode);
|
||||
XMLEncoder::GetInstance()->EncodeForPropertyType($normalizedValue, $oParentNode, $sPropertyTypeXML);
|
||||
}
|
||||
|
||||
public function UnserializeForPropertyType(DesignElement $oParentNode, string $sPropertyTypeXML): mixed
|
||||
{
|
||||
$oPropertyType = PropertyTypeCompiler::GetInstance()->CompilePropertyTypeFromXML($sPropertyTypeXML);
|
||||
$normalizedValue = XMLEncoder::GetInstance()->DecodeForPropertyType($oParentNode, $sPropertyTypeXML);
|
||||
|
||||
return $oPropertyType->UnserializeFromDOMNode($oParentNode);
|
||||
return XMLNormalizer::GetInstance()->DenormalizeForPropertyType($normalizedValue, $sPropertyTypeXML);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,20 +233,24 @@ PHP;
|
||||
return $this->oParent->GetChild($sId);
|
||||
}
|
||||
|
||||
public function SerializeToDOMNode(mixed $value, DesignElement $oDOMNode): void
|
||||
public function Normalize(mixed $value): mixed
|
||||
{
|
||||
$sXmlValue = $value;
|
||||
$oTextNode = $oDOMNode->ownerDocument->createTextNode($sXmlValue);
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function EncodeToDOMNode(mixed $normalizedValue, DesignElement $oDOMNode): void
|
||||
{
|
||||
$oTextNode = $oDOMNode->ownerDocument->createTextNode($normalizedValue);
|
||||
$oDOMNode->appendChild($oTextNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $oDOMNode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function UnserializeFromDOMNode(DesignElement $oDOMNode): mixed
|
||||
public function DecodeFromDomNode(DesignElement $oDOMNode): mixed
|
||||
{
|
||||
return $oDOMNode->GetText();
|
||||
}
|
||||
|
||||
public function Denormalize(mixed $normalizedValue): mixed
|
||||
{
|
||||
return $normalizedValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,13 +82,23 @@ class ValueTypeCollection extends ValueTypePropertyTree
|
||||
return $this->GetLocalPHPForValueType();
|
||||
}
|
||||
|
||||
public function SerializeToDOMNode(mixed $value, DesignElement $oDOMNode): void
|
||||
public function Normalize(mixed $value): mixed
|
||||
{
|
||||
$this->oXMLFormat->SerializeToDOMNode($value, $oDOMNode, $this);
|
||||
return $this->oXMLFormat->Normalize($value, $this);
|
||||
}
|
||||
|
||||
public function UnserializeFromDOMNode(DesignElement $oDOMNode): mixed
|
||||
public function EncodeToDOMNode(mixed $normalizedValue, DesignElement $oDOMNode): void
|
||||
{
|
||||
return $this->oXMLFormat->UnserializeFromDOMNode($oDOMNode, $this);
|
||||
$this->oXMLFormat->EncodeToDOMNode($normalizedValue, $oDOMNode, $this);
|
||||
}
|
||||
|
||||
public function DecodeFromDomNode(DesignElement $oDOMNode): mixed
|
||||
{
|
||||
return $this->oXMLFormat->DecodeFromDOMNode($oDOMNode, $this);
|
||||
}
|
||||
|
||||
public function Denormalize(mixed $normalizedValue): mixed
|
||||
{
|
||||
return $this->oXMLFormat->Denormalize($normalizedValue, $this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,4 +102,60 @@ PHP;
|
||||
|
||||
return $aResults;
|
||||
}
|
||||
|
||||
public function Normalize(mixed $value): mixed
|
||||
{
|
||||
$aNormalizedValues = [];
|
||||
|
||||
foreach ($this->aChildren as $oChild) {
|
||||
$sId = $oChild->sId;
|
||||
if (isset($value[$sId])) {
|
||||
$aNormalizedValues[$sId] = $oChild->Normalize($value[$sId]);
|
||||
}
|
||||
}
|
||||
|
||||
return $aNormalizedValues;
|
||||
}
|
||||
|
||||
public function EncodeToDOMNode(mixed $normalizedValue, DesignElement $oDOMNode): void
|
||||
{
|
||||
foreach ($this->aChildren as $oChild) {
|
||||
$sId = $oChild->sId;
|
||||
if (isset($normalizedValue[$sId])) {
|
||||
/** @var DesignElement $oChildNode */
|
||||
$oChildNode = $oDOMNode->ownerDocument->createElement($sId);
|
||||
$oDOMNode->appendChild($oChildNode);
|
||||
$oChild->EncodeToDOMNode($normalizedValue[$sId], $oChildNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function DecodeFromDomNode(DesignElement $oDOMNode): mixed
|
||||
{
|
||||
$aNormalizedValue = [];
|
||||
|
||||
foreach ($this->aChildren as $oChild) {
|
||||
$sId = $oChild->sId;
|
||||
$oChildNode = $oDOMNode->GetOptionalElement($sId);
|
||||
if ($oChildNode) {
|
||||
$aNormalizedValue[$sId] = $oChild->DecodeFromDomNode($oChildNode);
|
||||
}
|
||||
}
|
||||
|
||||
return $aNormalizedValue;
|
||||
}
|
||||
|
||||
public function Denormalize(mixed $normalizedValue): mixed
|
||||
{
|
||||
$aValues = [];
|
||||
|
||||
foreach ($this->aChildren as $oChild) {
|
||||
$sId = $oChild->sId;
|
||||
if (isset($normalizedValue[$sId])) {
|
||||
$aValues[$sId] = $oChild->Denormalize($normalizedValue[$sId]);
|
||||
}
|
||||
}
|
||||
|
||||
return $aValues;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,13 +42,23 @@ class ValueTypeCollectionOfValues extends AbstractLeafValueType
|
||||
parent::InitFromDomNode($oDomNode, $oParent);
|
||||
}
|
||||
|
||||
public function SerializeToDOMNode(mixed $value, DesignElement $oDOMNode): void
|
||||
public function Normalize(mixed $value): mixed
|
||||
{
|
||||
$this->oXMLFormat->SerializeToDOMNode($value, $oDOMNode, $this);
|
||||
return $this->oXMLFormat->Normalize($value, $this);
|
||||
}
|
||||
|
||||
public function UnserializeFromDOMNode(DesignElement $oDOMNode): mixed
|
||||
public function EncodeToDOMNode(mixed $normalizedValue, DesignElement $oDOMNode): void
|
||||
{
|
||||
return $this->oXMLFormat->UnserializeFromDOMNode($oDOMNode, $this);
|
||||
$this->oXMLFormat->EncodeToDOMNode($normalizedValue, $oDOMNode, $this);
|
||||
}
|
||||
|
||||
public function DecodeFromDomNode(DesignElement $oDOMNode): mixed
|
||||
{
|
||||
return $this->oXMLFormat->DecodeFromDOMNode($oDOMNode, $this);
|
||||
}
|
||||
|
||||
public function Denormalize(mixed $normalizedValue): mixed
|
||||
{
|
||||
return $this->oXMLFormat->Denormalize($normalizedValue, $this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ class XMLSerializerTest extends ItopDataTestCase
|
||||
/**
|
||||
* @dataProvider XMLSerializerProvider
|
||||
*
|
||||
* @param $inputContent
|
||||
* @param $normalizedValue
|
||||
* @param string $sPropertyTypeXML
|
||||
* @param string $sExpectedXMLContent
|
||||
* @param string $sXMLContent
|
||||
*
|
||||
* @return void
|
||||
* @throws \DOMException
|
||||
*/
|
||||
public function testSerializeXML($inputContent, string $sPropertyTypeXML, string $sExpectedXMLContent)
|
||||
public function testSerializeXML($normalizedValue, string $sPropertyTypeXML, string $sXMLContent)
|
||||
{
|
||||
ServiceLocator::GetInstance()->RegisterService('ModelReflection', new ModelReflectionRuntime());
|
||||
|
||||
@@ -34,18 +34,18 @@ class XMLSerializerTest extends ItopDataTestCase
|
||||
$oRootNode = $oDOMDocument->createElement('root');
|
||||
$oDOMDocument->appendChild($oRootNode);
|
||||
|
||||
Combodo\iTop\PropertyType\Serializer\XMLSerializer::GetInstance()->SerializeForPropertyType($inputContent, $oRootNode, $sPropertyTypeXML);
|
||||
Combodo\iTop\PropertyType\Serializer\XMLSerializer::GetInstance()->SerializeForPropertyType($normalizedValue, $oRootNode, $sPropertyTypeXML);
|
||||
|
||||
$sActualXML = $oDOMDocument->saveXML();
|
||||
|
||||
$this->AssertEqualiTopXML($sExpectedXMLContent, $sActualXML);
|
||||
$this->AssertEqualiTopXML($sXMLContent, $sActualXML);
|
||||
}
|
||||
|
||||
public function XMLSerializerProvider()
|
||||
{
|
||||
return [
|
||||
'Basic test should serialize to XML' => [
|
||||
'inputContent' => 'text',
|
||||
'normalizedValue' => 'text',
|
||||
'sPropertyTypeXML' => <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<property_type id="basic_test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
|
||||
@@ -54,13 +54,13 @@ class XMLSerializerTest extends ItopDataTestCase
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'sExpectedXMLContent' => <<<XML
|
||||
'sXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>text</root>
|
||||
XML,
|
||||
],
|
||||
'Collection of values as CSV' => [
|
||||
'inputContent' => ['Contact', 'Organization'],
|
||||
'normalizedValue' => ['Contact', 'Organization'],
|
||||
'sPropertyTypeXML' => <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<property_type id="basic_test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
|
||||
@@ -72,13 +72,13 @@ XML,
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'sExpectedXMLContent' => <<<XML
|
||||
'sXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>Contact,Organization</root>
|
||||
XML,
|
||||
],
|
||||
'Collection of values as id attribute' => [
|
||||
'inputContent' => ['Contact', 'Organization'],
|
||||
'normalizedValue' => ['Contact', 'Organization'],
|
||||
'sPropertyTypeXML' => <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<property_type id="class_test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
|
||||
@@ -92,7 +92,7 @@ XML,
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'sExpectedXMLContent' => <<<XML
|
||||
'sXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>
|
||||
<item id="Contact"/>
|
||||
@@ -101,7 +101,7 @@ XML,
|
||||
XML,
|
||||
],
|
||||
'Collection of tree as flat array' => [
|
||||
'inputContent' => [
|
||||
'normalizedValue' => [
|
||||
[
|
||||
'title_property' => 'title_a',
|
||||
'class_property' => 'class_a',
|
||||
@@ -132,7 +132,7 @@ XML,
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'sExpectedXMLContent' => <<<XML
|
||||
'sXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>
|
||||
<item_count>2</item_count>
|
||||
@@ -144,7 +144,7 @@ XML,
|
||||
XML,
|
||||
],
|
||||
'Property tree' => [
|
||||
'inputContent' => ['title_property' => 'title', 'class_property' => 'class'],
|
||||
'normalizedValue' => ['title_property' => 'title', 'class_property' => 'class'],
|
||||
'sPropertyTypeXML' => <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<property_type id="property_tree_test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
|
||||
@@ -162,7 +162,7 @@ XML,
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'sExpectedXMLContent' => <<<XML
|
||||
'sXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>
|
||||
<title_property>title</title_property>
|
||||
@@ -174,7 +174,7 @@ XML,
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider XMLUnserializerProvider
|
||||
* @dataProvider XMLSerializerProvider
|
||||
*
|
||||
* @param $sInputXMLContent
|
||||
* @param string $sPropertyTypeXML
|
||||
@@ -182,150 +182,17 @@ XML,
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUnserializeXML($sInputXMLContent, string $sPropertyTypeXML, $expectedValue)
|
||||
public function testUnserializeXML($normalizedValue, string $sPropertyTypeXML, string $sXMLContent)
|
||||
{
|
||||
ServiceLocator::GetInstance()->RegisterService('ModelReflection', new ModelReflectionRuntime());
|
||||
|
||||
$oDoc = new PropertyTypeDesign();
|
||||
$oDoc->loadXML($sInputXMLContent);
|
||||
$oDoc->loadXML($sXMLContent);
|
||||
/** @var \Combodo\iTop\DesignElement $oRoot */
|
||||
$oRoot = $oDoc->firstChild;
|
||||
|
||||
$aActualValue = Combodo\iTop\PropertyType\Serializer\XMLSerializer::GetInstance()->UnserializeForPropertyType($oRoot, $sPropertyTypeXML);
|
||||
|
||||
$this->assertEquals($expectedValue, $aActualValue);
|
||||
$this->assertEquals($normalizedValue, $aActualValue);
|
||||
}
|
||||
|
||||
public function XMLUnserializerProvider()
|
||||
{
|
||||
return [
|
||||
'Basic test should unserialize from XML' => [
|
||||
'sInputXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>text</root>
|
||||
XML,
|
||||
'sPropertyTypeXML' => <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<property_type id="basic_test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
|
||||
<extends>Dashlet</extends>
|
||||
<definition xsi:type="Combodo-ValueType-Label">
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'expectedValue' => 'text',
|
||||
],
|
||||
'Collection of values as CSV' => [
|
||||
'sInputXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>Contact,Organization</root>
|
||||
XML,
|
||||
'sPropertyTypeXML' => <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<property_type id="basic_test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
|
||||
<extends>Dashlet</extends>
|
||||
<definition xsi:type="Combodo-ValueType-CollectionOfValues">
|
||||
<xml-format xsi:type="Combodo-XMLFormat-CSV"/>
|
||||
<value-type xsi:type="Combodo-ValueType-Class">
|
||||
</value-type>
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'expectedValue' => ['Contact', 'Organization'],
|
||||
],
|
||||
'Collection of values as id attribute' => [
|
||||
'sInputXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>
|
||||
<item id="Contact"/>
|
||||
<item id="Organization"/>
|
||||
</root>
|
||||
XML,
|
||||
'sPropertyTypeXML' => <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<property_type id="class_test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
|
||||
<extends>Dashlet</extends>
|
||||
<definition xsi:type="Combodo-ValueType-CollectionOfValues">
|
||||
<xml-format xsi:type="Combodo-XMLFormat-ValueAsId">
|
||||
<tag-name>item</tag-name>
|
||||
</xml-format>
|
||||
<value-type xsi:type="Combodo-ValueType-Class">
|
||||
</value-type>
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'expectedValue' => ['Contact', 'Organization'],
|
||||
],
|
||||
'Collection of tree as flat array' => [
|
||||
'sInputXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>
|
||||
<item_count>2</item_count>
|
||||
<item_0_title_property>title_a</item_0_title_property>
|
||||
<item_0_class_property>class_a</item_0_class_property>
|
||||
<item_1_title_property>title_b</item_1_title_property>
|
||||
<item_1_class_property>class_b</item_1_class_property>
|
||||
</root>
|
||||
XML,
|
||||
'sPropertyTypeXML' => <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<property_type id="collection_test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
|
||||
<extends>Dashlet</extends>
|
||||
<definition xsi:type="Combodo-ValueType-Collection">
|
||||
<xml-format xsi:type="Combodo-XMLFormat-FlatArray">
|
||||
<count-tag>item_count</count-tag>
|
||||
<tag-format>item_\$rank\$_\$id\$</tag-format>
|
||||
</xml-format>
|
||||
<prototype>
|
||||
<node id="title_property" xsi:type="Combodo-ValueType-Label">
|
||||
<label>UI:BasicTest:Prop-Title</label>
|
||||
</node>
|
||||
<node id="class_property" xsi:type="Combodo-ValueType-Class">
|
||||
<label>UI:BasicTest:Prop-Class</label>
|
||||
<categories-csv>test</categories-csv>
|
||||
</node>
|
||||
</prototype>
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'expectedValue' => [
|
||||
[
|
||||
'title_property' => 'title_a',
|
||||
'class_property' => 'class_a',
|
||||
],
|
||||
[
|
||||
'title_property' => 'title_b',
|
||||
'class_property' => 'class_b',
|
||||
],
|
||||
],
|
||||
],
|
||||
'Property tree' => [
|
||||
'sInputXMLContent' => <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<root>
|
||||
<title_property>title</title_property>
|
||||
<class_property>class</class_property>
|
||||
</root>
|
||||
XML,
|
||||
'sPropertyTypeXML' => <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<property_type id="property_tree_test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
|
||||
<extends>Dashlet</extends>
|
||||
<definition xsi:type="Combodo-ValueType-PropertyTree">
|
||||
<nodes>
|
||||
<node id="title_property" xsi:type="Combodo-ValueType-Label">
|
||||
<label>UI:BasicTest:Prop-Title</label>
|
||||
</node>
|
||||
<node id="class_property" xsi:type="Combodo-ValueType-Class">
|
||||
<label>UI:BasicTest:Prop-Class</label>
|
||||
<categories-csv>test</categories-csv>
|
||||
</node>
|
||||
</nodes>
|
||||
</definition>
|
||||
</property_type>
|
||||
XML,
|
||||
'expectedValue' => ['title_property' => 'title', 'class_property' => 'class'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user