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

Create content_on_method enhancer #171

Open
ElectricMaxxx opened this issue Apr 3, 2016 · 28 comments
Open

Create content_on_method enhancer #171

ElectricMaxxx opened this issue Apr 3, 2016 · 28 comments

Comments

@ElectricMaxxx
Copy link
Member

To map REST routes (and other use cases) we need an enhancer for to map on controller methods based on the HTTP method.

The related discussion can be found: here There is also an example implementation mentioned or can be found here

The enhancer should be available in the bundle too.

@dbu
Copy link
Member

dbu commented Apr 4, 2016 via email

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 4, 2016 via email

@dbu
Copy link
Member

dbu commented Apr 4, 2016 via email

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 4, 2016 via email

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 4, 2016 via email

@dbu
Copy link
Member

dbu commented Apr 5, 2016

i would make the configuration something like

controller_by_class:
    My\Class:
        -
            methods: [put, post]
            controller: service:method
        -
            controller: service:readMethod
    Other\Class: service:method

so if the value of Other\Class is not a string but an array, it needs to be a list of subsets, the last of them can omit the methods filter to match everything that remains.

if you want complete automatic naming, you can use FOSRestBundle instead (and also customize methods and what not). or am i missing something that FOSRestBundle can not do that we would need with the CMF?

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 6, 2016 via email

@dbu
Copy link
Member

dbu commented Apr 6, 2016 via email

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 6, 2016 via email

@dbu
Copy link
Member

dbu commented Apr 6, 2016 via email

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 6, 2016 via email

@wouterj
Copy link
Member

wouterj commented Apr 6, 2016

I can help with the configuration btw :)

@wouterj wouterj closed this as completed Apr 6, 2016
@wouterj wouterj reopened this Apr 6, 2016
@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 6, 2016 via email

@wouterj
Copy link
Member

wouterj commented Apr 6, 2016

@ElectricMaxxx the RoutingAutoBundle does something similar, take a look at that one. You just need some normalizers.

@wouterj
Copy link
Member

wouterj commented Apr 6, 2016

E.g. Other\Class: service:method should be interpreted as a shortcut for Other\Class: [{ controller: service:method, methods: any }].

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 6, 2016 via email

@dbu
Copy link
Member

dbu commented Apr 6, 2016 via email

@wouterj
Copy link
Member

wouterj commented Apr 6, 2016

I don't think we should allow multiple documents to be routed to the same action. It seems very strange, each document should have a dedicated HTTP entry point imo (e.g. a BlogPost::createAction() shouldn't be able to created Pages imo).

My example was just to illustrate how you can do the configuration part. Given this example from @dbu:

controller_by_class:
    My\Class:
        -
            methods: [put, post]
            controller: service:method
        -
            controller: service:readMethod
    Other\Class: service:method

In order for configuration to support all these, the most long version should be used as standard and all others as shortcuts. So the above example in the long version will be something like:

controller_by_class:
    My\Class:
        -
            methods: [put, post]
            controller: service:method
        -
            method: [any] # please note that the dedicated PUT and POST methods will be handled by the previous configured controller
            controller: service:readMethod
    Other\Class:
        -
            methods: [any]
            controller: service:method

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 6, 2016 via email

@dbu
Copy link
Member

dbu commented Apr 7, 2016 via email

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented Apr 7, 2016 via email

@ElectricMaxxx
Copy link
Member Author

@wouterj yea i would need your help with the configuration as it is one level more complicated as the one in RoutingAutoBundle.

I started to implement some tests on the RestBundle, where i just implemented the old enhancer for testing it in a clean and combinded (Bundle + Component) environment. So The configuration is here the configuration i wanna inject is here or here. Simply wanted to get it into the configuration without any errors.

The error is a Unrecognized options "0, 1" under ..
Do i need one step deeper? Never did that. Whats wrong?

@ElectricMaxxx
Copy link
Member Author

I will try to work on this one on our slack day today.

@ElectricMaxxx
Copy link
Member Author

Yea ... i really would need some help with that configuration to work on.

@dbu
Copy link
Member

dbu commented May 2, 2016

do you have a WIP pull request that i can use as a starting point and try to fix?

@ElectricMaxxx
Copy link
Member Author

ElectricMaxxx commented May 2, 2016 via email

@ElectricMaxxx
Copy link
Member Author

@dbu i created two PRs.

@ElectricMaxxx
Copy link
Member Author

A part is done by implementing a ConditionalRouter in #174 to let him work we need to create that enahncer map in the DI extension of the bundle based on the given configuration.

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

3 participants