[DIC] Fixed: anonymous services are always private
This commit is contained in:
parent
8c222110c9
commit
7f4f9ab461
|
@ -278,18 +278,20 @@ class XmlFileLoader extends FileLoader
|
|||
// resolve definitions
|
||||
krsort($definitions);
|
||||
foreach ($definitions as $id => $def) {
|
||||
list($domElement, $file, $wild) = $def;
|
||||
|
||||
// anonymous services are always private
|
||||
$def[0]->setAttribute('public', false);
|
||||
// we could not use the constant false here, because of XML parsing
|
||||
$domElement->setAttribute('public', 'false');
|
||||
|
||||
$this->parseDefinition($id, $def[0], $def[1]);
|
||||
$this->parseDefinition($id, $domElement, $file);
|
||||
|
||||
$oNode = $def[0];
|
||||
if (true === $def[2]) {
|
||||
$nNode = new \DOMElement('_services', null, self::NS);
|
||||
$oNode->parentNode->replaceChild($nNode, $oNode);
|
||||
$nNode->setAttribute('id', $id);
|
||||
if (true === $wild) {
|
||||
$tmpDomElement = new \DOMElement('_services', null, self::NS);
|
||||
$domElement->parentNode->replaceChild($tmpDomElement, $domElement);
|
||||
$tmpDomElement->setAttribute('id', $id);
|
||||
} else {
|
||||
$oNode->parentNode->removeChild($oNode);
|
||||
$domElement->parentNode->removeChild($domElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,6 +184,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones');
|
||||
$inner = $services[(string) $args[0]];
|
||||
$this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
|
||||
$this->assertFalse($inner->isPublic());
|
||||
|
||||
// anonymous service as a property
|
||||
$properties = $services['foo']->getProperties();
|
||||
|
|
Reference in New Issue