Skip to content

How to change Subresource path #1479

Closed
Closed
@iCodr8

Description

@iCodr8

Is it possible to change the path of a subresource?

Activity

soyuka

soyuka commented on Nov 6, 2017

@soyuka
Member

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

iCodr8 commented on Nov 6, 2017

@iCodr8
ContributorAuthor

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

soyuka commented on Nov 7, 2017

@soyuka
Member

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

iCodr8 commented on Nov 7, 2017

@iCodr8
ContributorAuthor

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 :(

added a commit that references this issue on Nov 8, 2017
1c2bdcb
soyuka

soyuka commented on Nov 8, 2017

@soyuka
Member

Okaaayy. My bad thought this was fine!

iCodr8

iCodr8 commented on Nov 8, 2017

@iCodr8
ContributorAuthor

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

soyuka commented on Nov 8, 2017

@soyuka
Member

answer_get_subresource is the operation name

self-assigned this
on Nov 10, 2017
added a commit that references this issue on Nov 15, 2017
1e5b1ca
added a commit that references this issue on Nov 17, 2017

Merge pull request #1483 from soyuka/fix-subresource-override-operation

091865f
added a commit that references this issue on Nov 22, 2017
cf2ff41

5 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @iCodr8@soyuka

      Issue actions

        How to change Subresource path · Issue #1479 · api-platform/core