Skip to content

Commit

Permalink
[DependencyInjection] fixed anonymous services handling in XmlFileLoader
Browse files Browse the repository at this point in the history
Previous to this commit, it was not possible to have anonymous services
as arguments AND anonymous services in custom configs
  • Loading branch information
fabpot committed May 7, 2012
1 parent 1244158 commit 23b5e60
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
Expand Up @@ -229,27 +229,25 @@ private function processAnonymousServices(SimpleXMLElement $xml, $file)
$count = 0;

// anonymous services as arguments
if (false === $nodes = $xml->xpath('//container:argument[@type="service"][not(@id)]')) {
return;
}
foreach ($nodes as $node) {
// give it a unique name
$node['id'] = sprintf('%s_%d', md5($file), ++$count);
if (false !== $nodes = $xml->xpath('//container:argument[@type="service"][not(@id)]')) {
foreach ($nodes as $node) {
// give it a unique name
$node['id'] = sprintf('%s_%d', md5($file), ++$count);

$definitions[(string) $node['id']] = array($node->service, $file, false);
$node->service['id'] = (string) $node['id'];
$definitions[(string) $node['id']] = array($node->service, $file, false);
$node->service['id'] = (string) $node['id'];
}
}

// anonymous services "in the wild"
if (false === $nodes = $xml->xpath('//container:services/container:service[not(@id)]')) {
return;
}
foreach ($nodes as $node) {
// give it a unique name
$node['id'] = sprintf('%s_%d', md5($file), ++$count);
if (false !== $nodes = $xml->xpath('//container:services/container:service[not(@id)]')) {
foreach ($nodes as $node) {
// give it a unique name
$node['id'] = sprintf('%s_%d', md5($file), ++$count);

$definitions[(string) $node['id']] = array($node, $file, true);
$node->service['id'] = (string) $node['id'];
$definitions[(string) $node['id']] = array($node, $file, true);
$node->service['id'] = (string) $node['id'];
}
}

// resolve definitions
Expand Down

0 comments on commit 23b5e60

Please sign in to comment.