Skip to content
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

Future scope of Flow\Route #3335

Open
mhsdesign opened this issue Mar 27, 2024 · 2 comments
Open

Future scope of Flow\Route #3335

mhsdesign opened this issue Mar 27, 2024 · 2 comments

Comments

@mhsdesign
Copy link
Member

mhsdesign commented Mar 27, 2024

Flow\Route will be introduced via #3325

This issue will hold all followups.

1.) custom ControllerInterface + method annotation

We want to allow to attribute custom controllers with Flow\Route.

If the Flow\Action annotation is placed on a custom controller, it should behave a little less magic. See #3325 (comment)
(Custom controllers are currently unattractive but via the dispatcher overhaul they will be simpler to use #3311)
In comparison when being placed onto an ActionController we might not enforce the 'Action' suffix and pass the method name 1 by 1 to the @action route value:

class MySimpleController implements ControllerInterface
{
     // expected route config:
     // @package My.Package
     // @controller MySimple
     // @action myMethod
    #[Flow\Route(path: 'foo')]
    private function myMethod(ActionRequest $request, ActionResponse $response)
    {
    }

    public function processRequest(ActionRequest $request, ActionResponse $response)
    {
        $this->{$request->getControllerActionName()}($request, $response);
    }
}

Also we should contract by documentation of the ControllerInterface that it should be ensured that the method of the ActionRequest will be called.

2.) Allow to place and name controllers freely

... ControllerInterface must be implemented.

As discussed in https://discuss.neos.io/t/rfc-future-of-routing-mvc-in-flow/6535 we will refactor the routing values
to include the fully qualified controller name, so it can be easier generated without strong restrictions:

@controller My\Package\Controller\MyCustomController

instead of

@package My.Package
@controller MyCustom

3.)

Once @action is truly optional: https://discuss.neos.io/t/rfc-future-of-routing-mvc-in-flow/6535/5

we want to allow Flow\Route to be placed on classes directly:

// expected route config:
// @package My.Package
// @controller MyRest
#[Flow\Route(path: 'foo')]
class MyRestController extends RestController
{
    private function get()
    {
    }

    private function post()
    {
    }
}
mhsdesign added a commit to mficzel/flow-development-collection that referenced this issue Mar 27, 2024
@mhsdesign
Copy link
Member Author

Question about 2) would be if we would still support package activation like

Neos:
  Flow:
    mvc:
      "Some.Package": true

if the @controller contains the FQN and not the packageKey anymore? Or is this unrelated??

@sorenmalling
Copy link
Contributor

These are notes from the initial thoughts of the future of this annotation, that I want to share

  • Loose the Package attribute
  • routes having a identifier to be used for generate/resolving
  • have Class and method as parameters (no longer @controller and @action for resolving what class executes the HTTP request.
  • method be __invoke per default
  • required return value is a ResponseInterface

These are notes from the past - not a scheme for how it should be.
I hope that the merge today sparks joy 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants