Skip to content
Snippets Groups Projects
Verified Commit 638f8c36 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #10149 TIME 2 add new nature in xml

parent c03a439a
No related branches found
No related tags found
No related merge requests found
......@@ -2,4 +2,4 @@
php ./migrateSendmail.php
php ./migrateExport.php
php ./migrateFeature.php
php ./migrateNewNature.php
<?php
require '../../vendor/autoload.php';
chdir('../..');
$nonReadableFiles = [];
$customs = scandir('custom');
foreach ($customs as $custom) {
if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
continue;
}
$natures = [];
$path = "custom/{$custom}/apps/maarch_entreprise/xml/entreprise.xml";
if (file_exists($path)) {
if (!is_readable($path) || !is_writable($path)) {
$nonReadableFiles[] = $path;
continue;
}
$loadedXml = simplexml_load_file($path);
if ($loadedXml) {
$default_nature = (string)$loadedXml->mail_natures->default_nature;
unset($loadedXml->mail_natures->default_nature);
$newNature = $loadedXml->mail_natures->addChild('nature');
$newNature->addAttribute('with_reference', 'true');
$newNature->addChild('id', 'message_exchange');
$newNature->addChild('label', '_NUMERIC_PACKAGE');
$loadedXml->mail_natures->addChild('default_nature', $default_nature);
}
$res = formatXml($loadedXml);
$fp = fopen($path, "w+");
if ($fp) {
fwrite($fp, $res);
}
}
}
foreach ($nonReadableFiles as $file) {
printf("The file %s it is not readable or not writable.\n", $file);
}
function formatXml($simpleXMLElement)
{
$xmlDocument = new DOMDocument('1.0');
$xmlDocument->preserveWhiteSpace = false;
$xmlDocument->formatOutput = true;
$xmlDocument->loadXML($simpleXMLElement->asXML());
return $xmlDocument->saveXML();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment