@@ -259,11 +259,7 @@ private function parseDefinition(\DOMElement $service, $file, array $defaults =
259
259
if ($ function = $ factory ->getAttribute ('function ' )) {
260
260
$ definition ->setFactory ($ function );
261
261
} else {
262
- $ factoryService = $ this ->getChildren ($ factory , 'service ' );
263
-
264
- if (isset ($ factoryService [0 ])) {
265
- $ class = $ this ->parseDefinition ($ factoryService [0 ], $ file );
266
- } elseif ($ childService = $ factory ->getAttribute ('service ' )) {
262
+ if ($ childService = $ factory ->getAttribute ('service ' )) {
267
263
$ class = new Reference ($ childService , ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE );
268
264
} else {
269
265
$ class = $ factory ->hasAttribute ('class ' ) ? $ factory ->getAttribute ('class ' ) : null ;
@@ -278,11 +274,7 @@ private function parseDefinition(\DOMElement $service, $file, array $defaults =
278
274
if ($ function = $ configurator ->getAttribute ('function ' )) {
279
275
$ definition ->setConfigurator ($ function );
280
276
} else {
281
- $ configuratorService = $ this ->getChildren ($ configurator , 'service ' );
282
-
283
- if (isset ($ configuratorService [0 ])) {
284
- $ class = $ this ->parseDefinition ($ configuratorService [0 ], $ file );
285
- } elseif ($ childService = $ configurator ->getAttribute ('service ' )) {
277
+ if ($ childService = $ configurator ->getAttribute ('service ' )) {
286
278
$ class = new Reference ($ childService , ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE );
287
279
} else {
288
280
$ class = $ configurator ->getAttribute ('class ' );
@@ -379,13 +371,14 @@ private function processAnonymousServices(\DOMDocument $xml, $file)
379
371
$ xpath ->registerNamespace ('container ' , self ::NS );
380
372
381
373
// anonymous services as arguments/properties
382
- if (false !== $ nodes = $ xpath ->query ('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)] ' )) {
374
+ if (false !== $ nodes = $ xpath ->query ('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]|//container:factory[not(@service)]|//container:configurator[not(@service)] ' )) {
383
375
foreach ($ nodes as $ node ) {
384
- // give it a unique name
385
- $ id = sprintf ('%d_%s ' , ++$ count , hash ('sha256 ' , $ file ));
386
- $ node ->setAttribute ('id ' , $ id );
387
-
388
376
if ($ services = $ this ->getChildren ($ node , 'service ' )) {
377
+ // give it a unique name
378
+ $ id = sprintf ('%d_%s ' , ++$ count , hash ('sha256 ' , $ file ));
379
+ $ node ->setAttribute ('id ' , $ id );
380
+ $ node ->setAttribute ('service ' , $ id );
381
+
389
382
$ definitions [$ id ] = array ($ services [0 ], $ file , false );
390
383
$ services [0 ]->setAttribute ('id ' , $ id );
391
384
@@ -417,8 +410,6 @@ private function processAnonymousServices(\DOMDocument $xml, $file)
417
410
$ tmpDomElement = new \DOMElement ('_services ' , null , self ::NS );
418
411
$ domElement ->parentNode ->replaceChild ($ tmpDomElement , $ domElement );
419
412
$ tmpDomElement ->setAttribute ('id ' , $ id );
420
- } else {
421
- $ domElement ->parentNode ->removeChild ($ domElement );
422
413
}
423
414
}
424
415
}
0 commit comments