public function EntityRouteEnhancer::enhance in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer::enhance()
Updates the defaults for a route definition based on the request.
Parameters
array $defaults: The defaults, maps to '_defaults' in the route definition YAML.
\Symfony\Component\HttpFoundation\Request $request: The Request instance.
Return value
array The modified defaults. Each enhancer MUST return the $defaults but may add or remove values.
Overrides EnhancerInterface::enhance
File
- core/
lib/ Drupal/ Core/ Entity/ Enhancer/ EntityRouteEnhancer.php, line 18
Class
- EntityRouteEnhancer
- Enhances an entity form route with the appropriate controller.
Namespace
Drupal\Core\Entity\EnhancerCode
public function enhance(array $defaults, Request $request) {
$route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
if (!$this
->applies($route)) {
return $defaults;
}
if (empty($defaults['_controller'])) {
if (!empty($defaults['_entity_form'])) {
$defaults = $this
->enhanceEntityForm($defaults, $request);
}
elseif (!empty($defaults['_entity_list'])) {
$defaults = $this
->enhanceEntityList($defaults, $request);
}
elseif (!empty($defaults['_entity_view'])) {
$defaults = $this
->enhanceEntityView($defaults, $request);
}
}
return $defaults;
}