8000 bug #48027 [DependencyInjection] Don't autoconfigure tag when it's al… · symfony/symfony@67e0e87 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67e0e87

Browse files
committed
bug #48027 [DependencyInjection] Don't autoconfigure tag when it's already set with attributes (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Don't autoconfigure tag when it's already set with attributes | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #48019 | License | MIT | Doc PR | - Commits ------- f27ed9b [DependencyInjection] Don't autoconfigure tag when it's already set with attributes
2 parents f9eaefa + f27ed9b commit 67e0e87

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
129129
foreach ($instanceofTags[$i] as $k => $v) {
130130
if (null === $definition->getDecoratedService() || \in_array($k, $tagsToKeep, true)) {
131131
foreach ($v as $v) {
132-
if ($definition->hasTag($k) && \in_array($v, $definition->getTag($k))) {
132+
if ($definition->hasTag($k) && (!$v || \in_array($v, $definition->getTag($k)))) {
133133
continue;
134134
}
135135
$definition->addTag($k, $v);

src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ static function (ChildDefinition $definition, CustomAutoconfiguration $attribute
860860
$definition->addTag('app.custom_tag', get_object_vars($attribute) + ['class' => $reflector->getName()]);
861861
}
862862
);
863+
$container->registerForAutoconfiguration(TaggedService1::class)->addTag('app.custom_tag');
863864

864865
$container->register('one', TaggedService1::class)
865866
->setPublic(true)

0 commit comments

Comments
 (0)
0