[DI] Deal with inlined non-shared services
This commit is contained in:
parent
7a9875c3cd
commit
996698d996
@ -58,7 +58,11 @@ class AutowireExceptionPass implements CompilerPassInterface
|
||||
|
||||
// was the service inlined? Of so, does its parent service exist?
|
||||
if (isset($inlinedIds[$serviceId])) {
|
||||
return $this->doesServiceExistInTheContainer($inlinedIds[$serviceId], $container, $inlinedIds);
|
||||
foreach ($inlinedIds[$serviceId] as $parentId) {
|
||||
if ($this->doesServiceExistInTheContainer($parentId, $container, $inlinedIds)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -36,7 +36,7 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
||||
/**
|
||||
* Returns an array of all services inlined by this pass.
|
||||
*
|
||||
* The key is the inlined service id and its value is the service it was inlined into.
|
||||
* The key is the inlined service id and its value is the list of services it was inlined into.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -59,7 +59,7 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
||||
|
||||
if ($this->isInlineableDefinition($id, $definition, $this->container->getCompiler()->getServiceReferenceGraph())) {
|
||||
$this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
|
||||
$this->inlinedServiceIds[$id] = $this->currentId;
|
||||
$this->inlinedServiceIds[$id][] = $this->currentId;
|
||||
|
||||
if ($definition->isShared()) {
|
||||
return $definition;
|
||||
|
@ -65,9 +65,9 @@ class AutowireExceptionPassTest extends TestCase
|
||||
->method('getInlinedServiceIds')
|
||||
->will($this->returnValue(array(
|
||||
// a_service inlined into b_service
|
||||
'a_service' => 'b_service',
|
||||
'a_service' => array('b_service'),
|
||||
// b_service inlined into c_service
|
||||
'b_service' => 'c_service',
|
||||
'b_service' => array('c_service'),
|
||||
)));
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
@ -100,9 +100,9 @@ class AutowireExceptionPassTest extends TestCase
|
||||
->method('getInlinedServiceIds')
|
||||
->will($this->returnValue(array(
|
||||
// a_service inlined into b_service
|
||||
'a_service' => 'b_service',
|
||||
'a_service' => array('b_service'),
|
||||
// b_service inlined into c_service
|
||||
'b_service' => 'c_service',
|
||||
'b_service' => array('c_service'),
|
||||
)));
|
||||
|
||||
// do NOT register c_service in the container
|
||||
|
@ -273,7 +273,7 @@ class InlineServiceDefinitionsPassTest extends TestCase
|
||||
$repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), $inlinePass));
|
||||
$repeatedPass->process($container);
|
||||
|
||||
$this->assertEquals(array('inlinable.service' => 'other_service'), $inlinePass->getInlinedServiceIds());
|
||||
$this->assertEquals(array('inlinable.service' => array('other_service')), $inlinePass->getInlinedServiceIds());
|
||||
}
|
||||
|
||||
protected function process(ContainerBuilder $container)
|
||||
|
Reference in New Issue
Block a user