Executes the current command.
49 $miscXmlFilePath = $input->getArgument(
'path') . DIRECTORY_SEPARATOR .
"misc.xml";
50 $miscXmlFile = realpath($miscXmlFilePath);
51 $force = $input->getOption(
'force');
53 if ($miscXmlFile ===
false) {
56 $xml =
"<project version=\"4\"/>";
58 $miscXmlFile = realpath($miscXmlFilePath);
60 $exceptionMessage =
"misc.xml not found in given path '{$miscXmlFilePath}'";
62 ->error($exceptionMessage);
63 throw new TestFrameworkException($exceptionMessage);
66 $dom = new \DOMDocument(
'1.0');
67 $dom->preserveWhiteSpace =
false;
68 $dom->formatOutput =
true;
73 foreach($dom->getElementsByTagName(
'component') as $child) {
74 if ($child->getAttribute(
'name') ===
'ProjectResources') {
75 $nodeForWork = $child;
78 if ($nodeForWork ===
null) {
79 $project = $dom->getElementsByTagName(
'project')->item(0);
80 $nodeForWork = $dom->createElement(
'component');
81 $nodeForWork->setAttribute(
'name',
'ProjectResources');
87 $resourceNodes = $nodeForWork->getElementsByTagName(
'resource');
88 $resourceCount = $resourceNodes->length;
89 for (
$i = 0;
$i < $resourceCount;
$i++) {
90 $child = $resourceNodes[0];
91 $resources[$child->getAttribute(
'url')] = $child->getAttribute(
'location');
92 $child->parentNode->removeChild($child);
95 $resources = array_merge($resources, $this->generateResourcesArray());
97 foreach ($resources as
$url => $location) {
98 $resourceNode = $dom->createElement(
'resource');
99 $resourceNode->setAttribute(
'url',
$url);
100 $resourceNode->setAttribute(
'location', $location);
101 $nodeForWork->appendChild($resourceNode);
105 $dom->save($miscXmlFile);
106 $output->writeln(
"MFTF URN mapping successfully added to {$miscXmlFile}.");