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

Best way to add slug to IRI #833

Open
stepotronic opened this issue Sep 9, 2018 · 4 comments

Comments

Projects
None yet
4 participants
@stepotronic
Copy link

commented Sep 9, 2018

First, I would like to thank everybody involved in api-platform. It is an amazing project and I really like it.

I would like to use the slug generation offered in the doctrine extensions and make it part of the IRI. That works really well however I am stuck in adding this the IRI. I am asking here, because I believe there might be something that I can use. If you have any hints or pointers, please let me know.

 *     itemOperations={
 *         "get"={"method"="GET", "path"="/entity/{slug}/{id}", "requirements"={"id"="[a-f\d\-]+", "slug"="\w+"}},
 *         "put"={"method"="PUT", "path"="/entity/{slug}/{id}", "requirements"={"id"="[a-f\d\-]+", "slug"="\w+"}}
 *     }
`

Cheers,
Stepo
@mmplanet

This comment has been minimized.

Copy link

commented Sep 10, 2018

I have also described a similar problem here.

@soyuka

This comment has been minimized.

Copy link
Member

commented Sep 11, 2018

Hi,

I think that the easiest is to decorate the IriConverter. I made an example in this gist for one of my use cases. Obviously you'd need to change this guard and use whatever suits your needs.

@gnumoksha

This comment has been minimized.

Copy link

commented Mar 27, 2019

I'm wondering why one can't simply set the IRI for a given resource manually. It seems to me that API Platform tries to do a lot of magic but ignores people who prefer coding instead of relying on magic or memorizing conventions.

@soyuka

This comment has been minimized.

Copy link
Member

commented Mar 27, 2019

You can, just specify the iri attribute in your annotation or resource configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.