8000 [HttpKernel] Fix service arg resolver for controllers as array callables by sroze · Pull Request #24972 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] Fix service arg resolver for controllers as array callables #24972

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

Merged
merged 2 commits into from
Nov 16, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
[HttpKernel] Fix service arg resolver for controllers as array callables
  • Loading branch information
nicolas-grekas authored and sroze committed Nov 15, 2017
commit fc3d3bbf60617be6f76b8463ac6f24755d15d107
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@ public function __construct(ContainerInterface $container)
*/
public function supports(Request $request, ArgumentMetadata $argument)
{
return is_string($controller = $request->attributes->get('_controller')) && $this->container->has($controller) && $this->container->get($controller)->has($argument->getName());
$controller = $request->attributes->get('_controller');

if (\is_array($controller) && \is_callable($controller, true) && \is_string($controller[0])) {
$controller = $controller[0].'::'.$controller[1];
}

return \is_string($controller) && $this->container->has($controller) && $this->container->get($controller)->has($argument->getName());
}

/**
* {@inheritdoc}
*/
public function resolve(Request $request, ArgumentMetadata $argument)
{
yield $this->container->get($request->attributes->get('_controller'))->get($argument->getName());
if (\is_array($controller = $request->attributes->get('_controller'))) {
$controller = $controller[0].'::'.$controller[1];
}

yield $this->container->get($controller)->get($argument->getName());
}
}
0