There is a circular reference configuration pattern when defining custom operations.
On the one hand you need to ref the operation by name from within the route attributes and on the other hand you need to ref the route by name from within the operation configuration.
It so happened to me, that i broke the ref from route to operation, but i did not got any errors and warnings. the result was that i was wondering why my per-operation configuration wasnt applied.
you need to ref the operation by name from within the route attributes
Can you give an example to help illustrate?
@teohhanhui See https://api-platform.com/docs/core/operations#creating-custom-operations-and-controllers
You need to add "special"={"route_name"="book_special"} in the Resource class annotation and * defaults={"_api_resource_class"=Book::class, "_api_item_operation_name"="special"} in the controller annotation
The perfect behavior would be to only define custom operations on the controller/action and not on the Resource.
Or the opposite. Configuring everything from the resource will allow to find every operations in a quick look. And I think it will be easier to implement.
@dunglas True that. But it prevent extensibility from other sources in the app (third party bundles, etc). For example, one can have a Image resource defined in AcmeImageBundle, and when installing the AcmeImageCropBundle, it registers an operation to crop an Image.
I think the current way is a good middle ground. Both of the magical methods come with their own drawbacks...
What needs to be done here ?
Closing as we got no feedbacks. Feel free to ping me or to reopen if you find that something has to be done.