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

How to change Subresource path #1479

Closed
iCodr8 opened this issue Nov 6, 2017 · 7 comments
Closed

How to change Subresource path #1479

iCodr8 opened this issue Nov 6, 2017 · 7 comments
Assignees
Labels

Comments

@iCodr8
Copy link
Contributor

iCodr8 commented Nov 6, 2017

Is it possible to change the path of a subresource?

@soyuka
Copy link
Member

soyuka commented Nov 6, 2017

It should work just as you would overwrite the one of a collection operation.

For example:

# src/AppBundle/Resources/config/api_resources/resources.yml
AppBundle\Entity\Answer:
    collectionOperations:
        api_questions_answer_get_subresource:
            method: 'GET' # nothing more to add if we want to keep the default controller
            path: '/foo/{id}/bar'

Before you do this check debug:router to get the operation name and the identifier names (they'll have to stay the same).

docs

@iCodr8
Copy link
Contributor Author

iCodr8 commented Nov 6, 2017

When I am naming my collectionOperation to api_teams_users_get_subresource then it will be called api_teams_api_teams_users_get_subresource_collection in the router.

@soyuka
Copy link
Member

soyuka commented Nov 7, 2017

Mhh I need to change the docs on this itś s actually only the suffix. Just like you're doing to replace a collection operation (ie get, put) here it's property_get_subresource:

For example to replace the api_users_person_get_subresource_collection path I did:

        collectionOperations:
            person_get_subresource:
                method: 'GET'
                path: '/foo/{id}/bar'

@iCodr8
Copy link
Contributor Author

iCodr8 commented Nov 7, 2017

The problem is that i don't want to change the api_users_person_get_subresource_collection.
I want change the api_users_person_get_subresource and that's unfortunaley not possible at all :(

@soyuka
Copy link
Member

soyuka commented Nov 8, 2017

Okaaayy. My bad thought this was fine!

@iCodr8
Copy link
Contributor Author

iCodr8 commented Nov 8, 2017

So, the correct way was your first opinion?

# src/AppBundle/Resources/config/api_resources/resources.yml
AppBundle\Entity\Answer:
    collectionOperations:
        api_questions_answer_get_subresource:
            method: 'GET' # nothing more to add if we want to keep the default controller
            path: '/foo/{id}/bar'

@soyuka
Copy link
Member

soyuka commented Nov 8, 2017

answer_get_subresource is the operation name

@soyuka soyuka self-assigned this Nov 10, 2017
@soyuka soyuka added the bug label Nov 10, 2017
meyerbaptiste added a commit that referenced this issue Nov 17, 2017
fix #1479 allow to override SubresourceOperations through metadata
soyuka pushed a commit to soyuka/core that referenced this issue Nov 22, 2017
soyuka pushed a commit to soyuka/core that referenced this issue Nov 23, 2017
hoangnd25 pushed a commit to hoangnd25/core that referenced this issue Feb 23, 2018
hoangnd25 pushed a commit to hoangnd25/core that referenced this issue Feb 23, 2018
…ride-operation

fix api-platform#1479 allow to override SubresourceOperations through metadata
hoangnd25 pushed a commit to hoangnd25/core that referenced this issue Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants