By alexpott on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.5.x
Introduced in version:
11.5.0
Issue links:
Description:
A new interface \Drupal\Core\ParamConverter\ParamConverterRequirementsInterface has been introduced. Param converters that implement this interface can provide a regex pattern for route parameters they handle. The ParamConverterManager automatically calls getRouteRequirement() during route building and sets the returned regex as a route requirement, provided the route does not already define one for that parameter.
This allows routes to reject invalid parameter values at the routing level (before the param converter's convert() method is ever called), resulting in a faster 404 response with no unnecessary entity loading.
To take advantage of this feature in a custom param converter:
- Implement
ParamConverterRequirementsInterfacein addition toParamConverterInterface. - Return a regex string from
getRouteRequirement(), orNULLif no requirement can be determined for a given parameter definition.
Impacts:
Module developers