Autoconfig: don't automatically tag decorators
This commit is contained in:
parent
7535383163
commit
05ecf829fe
@ -113,6 +113,8 @@ class ResolveInstanceofConditionalsPass implements CompilerPassInterface
|
||||
$definition->setShared($shared);
|
||||
}
|
||||
|
||||
// Don't add tags to service decorators
|
||||
if (null === $definition->getDecoratedService()) {
|
||||
$i = \count($instanceofTags);
|
||||
while (0 <= --$i) {
|
||||
foreach ($instanceofTags[$i] as $k => $v) {
|
||||
@ -124,6 +126,7 @@ class ResolveInstanceofConditionalsPass implements CompilerPassInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$definition->setMethodCalls(array_merge($instanceofCalls, $definition->getMethodCalls()));
|
||||
$definition->setBindings($bindings + $instanceofBindings);
|
||||
|
@ -307,4 +307,26 @@ class ResolveInstanceofConditionalsPassTest extends TestCase
|
||||
$this->assertInstanceOf(BoundArgument::class, $bindings['$toto']);
|
||||
$this->assertSame(123, $bindings['$toto']->getValues()[0]);
|
||||
}
|
||||
|
||||
public function testDecoratorsAreNotAutomaticallyTagged()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$decorator = $container->register('decorator', self::class);
|
||||
$decorator->setDecoratedService('decorated');
|
||||
$decorator->setInstanceofConditionals([
|
||||
parent::class => (new ChildDefinition(''))->addTag('tag'),
|
||||
]);
|
||||
$decorator->setAutoconfigured(true);
|
||||
$decorator->addTag('manual');
|
||||
|
||||
$container->registerForAutoconfiguration(parent::class)
|
||||
->addTag('tag')
|
||||
;
|
||||
|
||||
(new ResolveInstanceofConditionalsPass())->process($container);
|
||||
(new ResolveChildDefinitionsPass())->process($container);
|
||||
|
||||
$this->assertSame(['manual' => [[]]], $container->getDefinition('decorator')->getTags());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user