8000 [HttpKernel] Fix services are no longer injected into __invoke contro… · symfony/symfony@ee44903 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee44903

Browse files
committed
[HttpKernel] Fix services are no longer injected into __invoke controllers method
1 parent 1403112 commit ee44903

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
3333
{
3434
private $resolverServiceId;
3535
private $controllerTag;
36+
private $controllerLocator;
3637

37-
public function __construct(string $resolverServiceId = 'argument_resolver.service', string $controllerTag = 'controller.service_arguments')
38+
public function __construct(string $resolverServiceId = 'argument_resolver.service', string $controllerTag = 'controller.service_arguments', string $controllerLocator = 'argument_resolver.controller_locator')
3839
{
3940
$this->resolverServiceId = $resolverServiceId;
4041
$this->controllerTag = $controllerTag;
42+
$this->controllerLocator = $controllerLocator;
4143
}
4244

4345
public function process(ContainerBuilder $container)
@@ -179,6 +181,8 @@ public function process(ContainerBuilder $container)
179181
}
180182

181183
$container->getDefinition($this->resolverServiceId)
182-
->replaceArgument(0, ServiceLocatorTagPass::register($container, $controllers));
184+
->replaceArgument(0, $controllerLocatorRef = ServiceLocatorTagPass::register($container, $controllers));
185+
186+
$container->setAlias($this->controllerLocator, (string) $controllerLocatorRef);
183187
}
184188
}

src/Symfony/Component/HttpKernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,16 @@
2121
*/
2222
class RemoveEmptyControllerArgumentLocatorsPass implements CompilerPassInterface
2323
{
24-
private $resolverServiceId;
24+
private $controllerLocator;
2525

26-
public function __construct(string $resolverServiceId = 'argument_resolver.service')
26+
public function __construct(string $controllerLocator = 'argument_resolver.controller_locator')
2727
{
28-
$this->resolverServiceId = $resolverServiceId;
28+
$this->controllerLocator = $controllerLocator;
2929
}
3030

3131
public function process(ContainerBuilder $container)
3232
{
33-
if (false === $container->hasDefinition($this->resolverServiceId)) {
34-
return;
35-
}
36-
37-
$serviceResolver = $container->getDefinition($this->resolverServiceId);
38-
$controllerLocator = $container->getDefinition((string) $serviceResolver->getArgument(0));
33+
$controllerLocator = $container->findDefinition($this->controllerLocator);
3934
$controllers = $controllerLocator->getArgument(0);
4035

4136
foreach ($controllers as $controller => $argumentRef) {

0 commit comments

Comments
 (0)
0