Problem/Motivation
I want to be able to tell to the entity param converter (EntityConverter
) which bundles to be converted on route where a param is an entity ID. For instance, I want to be able to create such a route definition:
some_route:
path: /node/{node}/foo
defaults:
_controller: ...
...
options:
parameters:
node:
type: entiity:node
bundles:
- blog
- article
With this definition I would expect that passing a node ID of a node of type 'blog' or 'article' to get the {node}
but when I pass a node ID of 'page' node to get a 404, as this route business purpose is to deal only with those node types and the route should "not exist" for other kind of nodes.
Proposed resolution
I've implemented this in our project by swapping the class of the paramconverter.entity
service but I see here some value that can be added to Drupal core.
Remaining tasks
None.
User interface changes
None.
API changes
Route parameters of type entity:*
accept a new bundle
definition property of type array.
Data model changes
None.
Release notes snippet
In order to limit the route entity parameters to certain bundles, a 'bundles' property, of type sequence, may be added to the parameter's definition.