N°5405 UpdateXML update tool now do a full file conversion

This commit is contained in:
Pierre Goiffon
2022-11-18 18:59:40 +01:00
parent 6258b97b92
commit d83c45812d
2 changed files with 18 additions and 9 deletions

View File

@@ -7,12 +7,11 @@
*
* datamodels/2.x/.../datamodel.*.xml
*
* Warning : this will NOT update the XML structure (iTopDesignFormat convert methods)
*
* Usage :
* `php .make\release\update-xml.php "1.7"`
*
* @since 2.7.0
* @since 2.7.0 simple version change using regexp (not doing conversion)
* @since 3.1.0 N°5405 now does a real conversion
******************************************************************************/

View File

@@ -174,11 +174,21 @@ class DatamodelsXmlFiles extends AbstractGlobFileVersionUpdater
*/
public function UpdateFileContent($sVersionLabel, $sFileContent, $sFileFullPath)
{
//TODO should also CONVERT files !
return preg_replace(
'/(<itop_design .* version=")[^"]+(">)/',
'${1}'.$sVersionLabel.'${2}',
$sFileContent
);
require_once APPROOT.'setup/itopdesignformat.class.inc.php';
$oFileXml = new DOMDocument();
/** @noinspection PhpComposerExtensionStubsInspection */
libxml_clear_errors();
$oFileXml->formatOutput = true;
$oFileXml->preserveWhiteSpace = false;
$oFileXml->loadXML($sFileContent);
$oFileItopFormat = new iTopDesignFormat($oFileXml);
$bConversionResult = $oFileItopFormat->Convert($sVersionLabel);
if (false === $bConversionResult) {
throw new Exception("Error when converting $sFileFullPath");
}
return $oFileItopFormat->GetXmlAsString();
}
}