I have created a custom resource which extends the EntityResource
class. This way I can use all build in functionality that Drupal core provides on the default entity resource, but I can still add some extra checks. This works perfectly fine.
I defined my canonical route in my resource as /api/my-endpoint/{node}. In this way, I can fetch and patch nodes by the node ID. After careful consideration, I want to implement /api/my-endpoint/{node_uuid} or even /api/my-endpoint/{node_custom_field} to fetch (and patch) a node by UUID.
Of course, Drupal doesn’t know this param and cannot load the corresponding node object, which results in fatal errors.
How can make I this work?
I tried to implement a custom RoutingParamConverter
class, but I didn’t got it to work.
Sponsored by SupremePR