Last active
August 29, 2015 14:11
-
-
Save adamquaile/f9569f5826828e75923f to your computer and use it in GitHub Desktop.
Remove "%service.class%" parameters from service container file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$inputFile = $argv[1]; | |
$config = simplexml_load_file($inputFile); | |
$paramMapping = []; | |
foreach ($config->parameters->parameter as $parameter) { | |
$key = $parameter->attributes()->key->__toString(); | |
$value = $parameter->__toString(); | |
if (preg_match('/(.*).class$/', $key)) { | |
$paramMapping[$key] = $value; | |
} | |
}; | |
$newContents = file_get_contents($inputFile); | |
foreach ($paramMapping as $key => $value) { | |
$newContents = str_replace('class="%' . $key . '%"', 'class="' . $value . '"', $newContents); | |
} | |
echo $newContents; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does most of the work, in most cases. Some manual editing will be required.