-
-
Notifications
You must be signed in to change notification settings - Fork 891
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
Configure route identifiers for subresources #1918
Comments
Oh you just want to customize parameters names. I looked into this and it's not supported (yet?). Indeed, they're generated in the SubresourceOperationFactory (and the names have a special meaning to find associations later in the SubresourceOperationDataProvider). I doubt that this would be an interesting feature though. About your data provider you should be able to create one without changing those identifiers names, they will be: <?php
[
'id' => 1, // customerId, or the root of the subresource
'entityTypes' => 2 // entity type id
] One thing that may work is to override the whole path of the subresource operation (see custom operation in the docs) and add your own data provider. |
That's what I do, the problem is, APIP generates several routes and the parameter names conflict with each other. Example: Second generated route
You mean creating custom controllers https://api-platform.com/docs/core/operations/#creating-custom-operations-and-controllers? |
They don't conflict, I mean for 1 route there are no parameters with the same name :).
Yes, the You should be able to override the subresource operation path:
|
Thanks, The route is now correct ( |
yes but your links don't mention the possibility to rewrite the parameter names of the default routes (getItem, getSubresource, etc.). |
I guess there is some more work to be done here then :). What would be a potential solution for your issue? |
Not sure. I think of two solutions. First one is by stop hacking around Api Platform and do it from scratch (I already developed a "domain" layer which is framework asgnostic. I wanted to see if I could easily connect my domain model to APIP to delegate it all the REST concerns). The second one is by stop trying to decouple from a domain layer and do it the APIP way by bringing back DoctrineORM and generate anemic Doctrine entities and using all the magic APIP provides for CRUD & RAD based apps. |
related to api-platform/api-platform#1022 merged in #2706 |
Hi,
is it possible to customize the route identifier names in ApiPlatform when using subresources?
Example:
I want my route
/api/customers/{id}/entity_types/{entityTypes}/layouts
to become
/api/customers/{customerId}/entity_types/{entityTypeId}/layouts
so that I can easily implement a custom SubresourceDataProviderInterface.
I quickly tried to figure out where the magic was done and found out this method
core/src/Operation/Factory/SubresourceOperationFactory.php
Line 114 in d9d0e04
For me it looks like it's not configurable but I wanted to ask to be sure.
Thanks.
The text was updated successfully, but these errors were encountered: