Skip to content

[DependencyInjection] fix support of inherited tags in child services definitions. #21629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function __construct()
$this->beforeOptimizationPasses = array(
100 => array(
$resolveClassPass = new ResolveClassPass(),
new ResolveDefinitionTemplatesPass(),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testPassOrdering()
$config->addPass($pass2, PassConfig::TYPE_BEFORE_OPTIMIZATION, 30);

$passes = $config->getBeforeOptimizationPasses();
$this->assertSame($pass2, $passes[1]);
$this->assertSame($pass1, $passes[2]);
$this->assertSame($pass2, $passes[2]);
$this->assertSame($pass1, $passes[3]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,38 @@ public function testProcessResolvesAliases()
$this->assertSame('ParentClass', $def->getClass());
}

public function testProcessInheritTags()
{
$container = new ContainerBuilder();

$container->register('parent', 'ParentClass')->addTag('some.tag', array('foo' => 'bar'));

$definition = (new ChildDefinition('parent'))
->setInheritTags(true)
->addTag('other.tag')
->addTag('some.tag', array('bar' => 'foo'));

$container->setDefinition('child', $definition);

$this->process($container);

$definition = $container->getDefinition('child');
$this->assertSame('ParentClass', $definition->getClass());
$this->assertCount(2, $definition->getTags());
$this->assertSame(
array(
'other.tag' => array(
array(),
),
'some.tag' => array(
array('bar' => 'foo'),
array('foo' => 'bar'),
),
),
$definition->getTags()
);
}

protected function process(ContainerBuilder $container)
{
$pass = new ResolveDefinitionTemplatesPass();
Expand Down