Skip to content

Commit fc3d3bb

Browse files
nicolas-grekassroze
authored andcommitted
[HttpKernel] Fix service arg resolver for controllers as array callables
1 parent a9e9f36 commit fc3d3bb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,24 @@ public function __construct(ContainerInterface $container)
3535
*/
3636
public function supports(Request $request, ArgumentMetadata $argument)
3737
{
38-
return is_string($controller = $request->attributes->get('_controller')) && $this->container->has($controller) && $this->container->get($controller)->has($argument->getName());
38+
$controller = $request->attributes->get('_controller');
39+
40+
if (\is_array($controller) && \is_callable($controller, true) && \is_string($controller[0])) {
41+
$controller = $controller[0].'::'.$controller[1];
42+
}
43+
44+
return \is_string($controller) && $this->container->has($controller) && $this->container->get($controller)->has($argument->getName());
3945
}
4046

4147
/**
4248
* {@inheritdoc}
4349
*/
4450
public function resolve(Request $request, ArgumentMetadata $argument)
4551
{
46-
yield $this->container->get($request->attributes->get('_controller'))->get($argument->getName());
52+
if (\is_array($controller = $request->attributes->get('_controller'))) {
53+
$controller = $controller[0].'::'.$controller[1];
54+
}
55+
56+
yield $this->container->get($controller)->get($argument->getName());
4757
}
4858
}

0 commit comments

Comments
 (0)