8000 bug #49867 [DependencyInjection] Filter "container.excluded" services… · symfony/symfony@3b9fa3c · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b9fa3c

Browse files
bug #49867 [DependencyInjection] Filter "container.excluded" services when using findTaggedServiceIds() (nicolas-grekas)
This PR was merged into the 6.2 branch. Discussion ---------- [DependencyInjection] Filter "container.excluded" services when using `findTaggedServiceIds()` | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - As spotted by `@stof` in #49850 (comment) Commits ------- cf3d67e [DependencyInjection] Filter "container.excluded" services when using `findTaggedServiceIds()`
2 parents cb71df8 + cf3d67e commit 3b9fa3c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ public function findTaggedServiceIds(string $name, bool $throwOnAbstract = false
12121212
$this->usedTags[] = $name;
12131213
$tags = [];
12141214
foreach ($this->getDefinitions() as $id => $definition) {
1215-
if ($definition->hasTag($name)) {
1215+
if ($definition->hasTag($name) && !$definition->hasTag('container.excluded')) {
12161216
if ($throwOnAbstract && $definition->isAbstract()) {
12171217
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must not be abstract.', $id, $name));
12181218
}

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,11 @@ public function testfindTaggedServiceIds()
928928
->addTag('bar', ['bar' => 'bar'])
929929
->addTag('foo', ['foofoo' => 'foofoo'])
930930
;
931+
$builder
932+
->register('bar', 'Bar\FooClass')
933+
->addTag('foo')
934+
->addTag('container.excluded')
935+
;
931936
$this->assertEquals([
932937
'foo' => [
933938
['foo' => 'foo'],

0 commit comments

Comments
 (0)
0