Skip to content

Instantly share code, notes, and snippets.

@adamquaile
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamquaile/f9569f5826828e75923f to your computer and use it in GitHub Desktop.
Save adamquaile/f9569f5826828e75923f to your computer and use it in GitHub Desktop.
Remove "%service.class%" parameters from service container file
<?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;
@adamquaile
Copy link
Author

Does most of the work, in most cases. Some manual editing will be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment