Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | no |
Symfony version | 3.3.0-dev |
Invokable controllers are coming! In routing config they're already addressable using a FQCN e.g. in a routing YAML:
home:
path: /home
defaults: { _controller: AppBundle\Controller\HomeController::__invoke }
And when #22330 is merged we can drop the __invoke:
defaults: { _controller: AppBundle\Controller\HomeController }
When defining routes it would be good to to also support invokable controllers using the shorter colon-based syntax. Currently the ControllerResolver / ControllerNameParser can't handle these two cases:
defaults: { _controller: AppBundle:Home:__invoke }
fails as it resolves to AppBundle\Controller\HomeController::__invokeAction
which doesn't work for obvious reasons. Fixing this would be a case of not transforming __invoke into __invokeAction in the ControllerNameParser.
defaults: { _controller: AppBundle:Home }
Fails as this format doesn't get passed into the ControllerNameParser to be parsed in the ControllerResolver so thus results in a ServiceNotFoundException
.
Expected Behaviour
Both AppBundle:Home
and AppBundle:Home:__invoke
should resolve to invoking AppBundle\Controller\HomeController
.
(This ticket was spun out from comments on #22202).