Parameter converter for upcasting entity IDs to full objects.
This is useful in cases where the dynamic elements of the path can't be auto-determined; for example, if your path refers to multiple of the same type of entity ("example/{node1}/foo/{node2}") or if the path can act on any entity type ("example/{entity_type}/{entity}/foo").
In order to use it you should specify some additional options in your route:
example.route: path: foo/{example} options: parameters: example: type: entity:node
If you want to have the entity type itself dynamic in the url you can specify it like the following:
example.route: path: foo/{entity_type}/{example} options: parameters: example: type: entity:{entity_type}
Hierarchy
- class \Drupal\Core\ParamConverter\EntityConverter implements ParamConverterInterface
File
- core/lib/Drupal/Core/ParamConverter/EntityConverter.php, line 39
Namespace
Drupal\Core\ParamConverter
Members
Name | Modifiers | Type | Description |
---|---|---|---|
EntityConverter::$entityManager | protected | property | Entity manager which performs the upcasting in the end. |
EntityConverter::applies | public | function | Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies |
EntityConverter::convert | public | function | Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert |
EntityConverter::getEntityTypeFromDefaults | protected | function | Determines the entity type ID given a route definition and route defaults. |
EntityConverter::__construct | public | function | Constructs a new EntityConverter. |
Please login to continue.