X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FRouting%2FEnhancer%2FEntityRevisionRouteEnhancer.php;h=d54338f449146678507e476d6269c4d326bd8ac4;hb=refs%2Fheads%2Fd864;hp=9880edd5237e12ff28d5eb4d5af272d6c9afce16;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php b/web/core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php index 9880edd52..d54338f44 100644 --- a/web/core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php +++ b/web/core/lib/Drupal/Core/Routing/Enhancer/EntityRevisionRouteEnhancer.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Routing\Enhancer; +use Drupal\Core\Routing\EnhancerInterface; use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Route; @@ -9,12 +10,17 @@ use Symfony\Component\Routing\Route; /** * Adds _entity_revision to the request attributes, if possible. */ -class EntityRevisionRouteEnhancer implements RouteEnhancerInterface { +class EntityRevisionRouteEnhancer implements EnhancerInterface { /** - * {@inheritdoc} + * Returns whether the enhancer runs on the current route. + * + * @param \Symfony\Component\Routing\Route $route + * The current route. + * + * @return bool */ - public function applies(Route $route) { + protected function applies(Route $route) { // Check whether there is any entity revision parameter. $parameters = $route->getOption('parameters') ?: []; foreach ($parameters as $info) { @@ -31,6 +37,10 @@ class EntityRevisionRouteEnhancer implements RouteEnhancerInterface { 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) {