Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Matching different controller for each HTTP method #196

Open
damienflament opened this issue Apr 11, 2017 · 1 comment
Open

Matching different controller for each HTTP method #196

damienflament opened this issue Apr 11, 2017 · 1 comment

Comments

@damienflament
Copy link
Contributor

damienflament commented Apr 11, 2017

I want to match a different controller action for each HTTP method on a single URI.
The nicest way to do this might be:

App\Document\Page:
    uri_schema: /{title}
    definitions:
        view:
            methods: [GET]
            defaults:
                _controller: App:Page:view
        edit:
            methods: [PATCH]
            defaults:
                _controller: App:Page:edit
    token_poviders:
        title: [content_method, {method: getTitle}]

As the uri_schema key is validated by the YmlFileLoader but not handled as a mapping key, I tried this:

 App\Document\Page:
    definitions:
        view:
            uri_schema: /{title}
            methods: [GET]
            defaults:
                _controller: App:Page:view
        edit:
            uri_schema: /{title}
            methods: [PATCH]
            defaults:
                _controller: App:Page:edit
    token_poviders:
        title: [content_method, {method: getTitle}]

But the methods key is not handled.

What's the good way to add HTTP method requirements like with the standard Symfony router ?

@dantleech
Copy link
Member

dantleech commented Apr 14, 2017

Looks like a valid feature to me. Feel free to PR - you will just have to add the key to the loader(s) and ensure that the (PHPCR-ODM) adapter persists the method on the Route object (which already has a method setMethods(array $methods) iirc)

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

No branches or pull requests

2 participants