Usually routes have the {entity_type} argument in their path and Drupal loads the entity by the ID that is the url argument. For example route defining /node/{node} would work with /node/5.

I need to load the entity not by it's ID but rather UUID. So the path would look like /node/0ff3b31b-5abb-4377-bb00-af71882e38a4

Is it possible to load the entity by UUID by defining some sort of mapping in the route definition or do I have to create my own ParamConverter for this?


Yes, you need your own param converter for this, the default implementation can only load by UUID.

Loading by UUID is less performant as long as the primary ID is still a serial ID, this means that it first needs to do an entity query to fetch the ID and then load that.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy