Skip to content

[FrameworkBundle][DX] ControllerNameParser does not handle invokable controllers #22338

@BPScott

Description

@BPScott
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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy