function EntityRevisionRouteEnhancer::enhance
Same name in other branches
- 9 core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php \Drupal\Core\Routing\Enhancer\EntityRevisionRouteEnhancer::enhance()
- 8.9.x core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php \Drupal\Core\Routing\Enhancer\EntityRevisionRouteEnhancer::enhance()
- 10 core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php \Drupal\Core\Routing\Enhancer\EntityRevisionRouteEnhancer::enhance()
Overrides EnhancerInterface::enhance
File
-
core/
lib/ Drupal/ Core/ Routing/ Enhancer/ EntityRevisionRouteEnhancer.php, line 37
Class
- EntityRevisionRouteEnhancer
- Adds _entity_revision to the request attributes, if possible.
Namespace
Drupal\Core\Routing\EnhancerCode
public function enhance(array $defaults, Request $request) {
/** @var \Symfony\Component\Routing\Route $route */
$route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
if (!$this->applies($route)) {
return $defaults;
}
$options = $route->getOptions();
if (isset($options['parameters'])) {
foreach ($options['parameters'] as $name => $details) {
if (!empty($details['type']) && str_contains($details['type'], 'entity_revision:')) {
$defaults['_entity_revision'] = $defaults[$name];
break;
}
}
}
return $defaults;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.