Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitde33b25

Browse files
committed
[DependencyInjection] Process bindings in ServiceLocatorTagPass
1 parent0eebba6 commitde33b25

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ protected function processValue($value, $isRoot = false)
3939
returnself::register($this->container,$value->getValues());
4040
}
4141

42+
if ($valueinstanceof Definition) {
43+
$value->setBindings(parent::processValue($value->getBindings()));
44+
}
45+
4246
if (!$valueinstanceof Definition || !$value->hasTag('container.service_locator')) {
4347
returnparent::processValue($value,$isRoot);
4448
}

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
usePHPUnit\Framework\TestCase;
1515
useSymfony\Component\DependencyInjection\Argument\BoundArgument;
16+
useSymfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
1617
useSymfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
1718
useSymfony\Component\DependencyInjection\ContainerBuilder;
1819
useSymfony\Component\DependencyInjection\Exception\InvalidArgumentException;
@@ -143,4 +144,16 @@ public function testBindingsAreCopied()
143144
$this->assertSame(['foo'],array_keys($locator->getBindings()));
144145
$this->assertInstanceOf(BoundArgument::class,$locator->getBindings()['foo']);
145146
}
147+
148+
publicfunctiontestBindingsAreRegistered()
149+
{
150+
$container =newContainerBuilder();
151+
152+
$definition =$container->register('foo')
153+
->setBindings(['foo' =>newServiceLocatorArgument()]);
154+
155+
(newServiceLocatorTagPass())->process($container);
156+
157+
$this->assertInstanceOf(Reference::class,$definition->getBindings()['foo']->getValues()[0]);
158+
}
146159
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp