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

[Routing] Allow to import multiple resources #2145

Closed
wants to merge 3 commits into from

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Sep 9, 2011

This change has been requested by @lsmith77 and @merk for the FosRestBundle.

Multiple resources can be imported at once, see xml and yml examples in the tests.
(The xml files is probably not the best example as you would probably remove the attribute and use child nodes only when importing multiple resources - being able to use both is required to keep BC).

This change is BC.

@lsmith77
Copy link
Contributor

lsmith77 commented Sep 9, 2011

just as a quick background the aim is to be able to configure multiple resources to handle API versioning: FriendsOfSymfony/FOSRestBundle#12


if (isset($config['resources'])) {
$config['resources'] = (array) $config['resources'];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be done before parsing the resources ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry, I missed the fact it is a method called before the other change.

@fabpot
Copy link
Member

fabpot commented Sep 11, 2011

Which problem does it solve?

What's the difference between:

blog_show:
    resources: [validpattern.yml, validpattern.2.yml]

and:

blog_show_1:
    resources: validpattern.yml

blog_show_2:
    resources: validpattern.2.yml

@lsmith77
Copy link
Contributor

the point is that this way we can easily define a relation between the resources. in our particular use case the relation is that there is a set of controller classes/services that all are providing different versions of the same API.

@fabpot
Copy link
Member

fabpot commented Sep 11, 2011

You can define a relation by adding a special option:

blog_show_1:
    resources: validpattern.yml
    options: { version: 1.0 }

blog_show_2:
    resources: validpattern.2.yml
    options: { version: 2.0 }

Routing is about parsing the URL and converting it into parameters. Your request is about something different, which does not belong to the Routing.

@lsmith77
Copy link
Contributor

Sure thats possible and we have already considered this:
FriendsOfSymfony/FOSRestBundle#12 (comment)

Its just that things will be easier and cleaner with the support for resources. I do not think that my request is about anything different than route generation, but sure it can be considered syntactical sugar to some extend.

@fabpot
Copy link
Member

fabpot commented Nov 22, 2011

Now that a resource can have some requirements and some defaults attached to it, I'm sure how this patch can be still relevant. Do we assume that all resources have the same requirements and defaults?

@lsmith77
Copy link
Contributor

I will try to play with this all over the weekend. I went back and forth with lots of design ideas and I don't have a perfect overview in my head anymore what I need specifically. I do remember that I realized that I really need to do the matching inside the Router. I don't remember if that makes this PR no longer necessary for that particular use case.

@fabpot
Copy link
Member

fabpot commented Dec 2, 2011

@lsmith77: any update on this PR? Is it still needed for you?

@lsmith77
Copy link
Contributor

lsmith77 commented Dec 2, 2011

sorry .. no. i didn't get to it last weekend and this weekend i am off. so probably not until christmas so i guess it will not be relevant for 2.1 after all. hopefully when i do work on i will discover that its no longer needed :)

@fabpot
Copy link
Member

fabpot commented Jan 22, 2012

@lsmith77: any news in this PR?

@lsmith77
Copy link
Contributor

no sorry. i have been so busy with PHPCR, that i havent found any time to work on bigger improvements in FOSRestBundle.

On 22.01.2012, at 10:46, Fabien Potencier reply@reply.github.com wrote:

@lsmith77: any news in this PR?


Reply to this email directly or view it on GitHub:
#2145 (comment)

@fabpot
Copy link
Member

fabpot commented Feb 2, 2012

Closing this PR as I don't think that we can assume that all resources can share the same requirements and defaults.

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

Successfully merging this pull request may close these issues.

None yet

5 participants