diff --git a/migration/19.10/migrate.sh b/migration/19.10/migrate.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc4438c45c2e8b635fca9d0ea7d0eb84a0dc024e --- /dev/null +++ b/migration/19.10/migrate.sh @@ -0,0 +1,2 @@ +#!/bin/sh +php ./migrateServicesEntities.php diff --git a/migration/19.10/migrateServicesEntities.php b/migration/19.10/migrateServicesEntities.php new file mode 100644 index 0000000000000000000000000000000000000000..a3177d166873233fb88b36d314e20555a1c8faa2 --- /dev/null +++ b/migration/19.10/migrateServicesEntities.php @@ -0,0 +1,58 @@ +<?php + +require '../../vendor/autoload.php'; + +chdir('../..'); + +$nonReadableFiles = []; +$migrated = 0; +$customs = scandir('custom'); + +foreach ($customs as $custom) { + if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') { + continue; + } + + $natures = []; + $path = "custom/{$custom}/modules/entities/xml/services.xml"; + if (file_exists($path)) { + if (!is_readable($path) || !is_writable($path)) { + $nonReadableFiles[] = $path; + continue; + } + $loadedXml = simplexml_load_file($path); + + if ($loadedXml) { + $i = 0; + foreach ($loadedXml->SERVICE as $value) { + if ($value->id == 'entities_print_sep_mlb') { + $loadedXml->SERVICE[$i]->servicepage = '/separators/print'; + $loadedXml->SERVICE[$i]->angular = 'true'; + } + ++$i; + } + $res = formatXml($loadedXml); + $fp = fopen($path, "w+"); + if ($fp) { + fwrite($fp, $res); + $migrated++; + } + } + } +} + +foreach ($nonReadableFiles as $file) { + printf("The file %s it is not readable or not writable.\n", $file); +} + +printf($migrated . " custom(s) avec services.xml (entities) trouvé(s) et migré(s).\n"); + +function formatXml($simpleXMLElement) +{ + $xmlDocument = new DOMDocument('1.0'); + $xmlDocument->preserveWhiteSpace = false; + $xmlDocument->formatOutput = true; + $xmlDocument->loadXML($simpleXMLElement->asXML()); + + return $xmlDocument->saveXML(); +}