diff --git a/core/lib/Drupal/Core/Routing/Router.php b/core/lib/Drupal/Core/Routing/Router.php index 29b2ee10dd..ef7bea019d 100644 --- a/core/lib/Drupal/Core/Routing/Router.php +++ b/core/lib/Drupal/Core/Routing/Router.php @@ -4,6 +4,7 @@ use Drupal\Core\Path\CurrentPathStack; use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface; +use \Drupal\Core\Routing\Enhancer\RouteEnhancerInterface as LegacyRouteEnhancerInterface; use Symfony\Cmf\Component\Routing\LazyRouteCollection; use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Cmf\Component\Routing\RouteProviderInterface as BaseRouteProviderInterface; @@ -254,9 +255,10 @@ protected function getInitialRouteCollection(Request $request) { */ protected function applyRouteEnhancers($defaults, Request $request) { foreach ($this->enhancers as $enhancer) { - if ($enhancer instanceof RouteEnhancerInterface || $enhancer->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) { - $defaults = $enhancer->enhance($defaults, $request); + if ($enhancer instanceof LegacyRouteEnhancerInterface && !$enhancer->applies($defaults[RouteObjectInterface::ROUTE_OBJECT)) { + continue; } + $defaults = $enhancer->enhance($defaults, $request); } return $defaults; diff --git a/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php b/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php index 87d924654e..052e74f35b 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php @@ -49,36 +49,36 @@ public function testContentRouting() { // ['path', 'accept', 'content-type'], // Extension is part of the route path. Constant Content-type. -// ['conneg/simple.json', '', 'application/json'], -// ['conneg/simple.json', 'application/xml', 'application/json'], -// ['conneg/simple.json', 'application/json', 'application/json'], + ['conneg/simple.json', '', 'application/json'], + ['conneg/simple.json', 'application/xml', 'application/json'], + ['conneg/simple.json', 'application/json', 'application/json'], // No extension. Constant Content-type. -// ['conneg/html', '', 'text/html'], -// ['conneg/html', '*/*', 'text/html'], -// ['conneg/html', 'application/xml', 'text/html'], -// ['conneg/html', 'text/xml', 'text/html'], -// ['conneg/html', 'text/html', 'text/html'], + ['conneg/html', '', 'text/html'], + ['conneg/html', '*/*', 'text/html'], + ['conneg/html', 'application/xml', 'text/html'], + ['conneg/html', 'text/xml', 'text/html'], + ['conneg/html', 'text/html', 'text/html'], // Dynamic extension. Linked Content-type. ['conneg/html?_format=json', '', 'application/json'], -// ['conneg/html?_format=json', '*/*', 'application/json'], -// ['conneg/html?_format=json', 'application/xml', 'application/json'], -// ['conneg/html?_format=json', 'application/json', 'application/json'], -// ['conneg/html?_format=xml', '', 'application/xml'], -// ['conneg/html?_format=xml', '*/*', 'application/xml'], -// ['conneg/html?_format=xml', 'application/json', 'application/xml'], -// ['conneg/html?_format=xml', 'application/xml', 'application/xml'], + ['conneg/html?_format=json', '*/*', 'application/json'], + ['conneg/html?_format=json', 'application/xml', 'application/json'], + ['conneg/html?_format=json', 'application/json', 'application/json'], + ['conneg/html?_format=xml', '', 'application/xml'], + ['conneg/html?_format=xml', '*/*', 'application/xml'], + ['conneg/html?_format=xml', 'application/json', 'application/xml'], + ['conneg/html?_format=xml', 'application/xml', 'application/xml'], // Path with a variable. Variable contains a period. -// ['conneg/plugin/plugin.id', '', 'text/html'], -// ['conneg/plugin/plugin.id', '*/*', 'text/html'], -// ['conneg/plugin/plugin.id', 'text/xml', 'text/html'], -// ['conneg/plugin/plugin.id', 'text/html', 'text/html'], + ['conneg/plugin/plugin.id', '', 'text/html'], + ['conneg/plugin/plugin.id', '*/*', 'text/html'], + ['conneg/plugin/plugin.id', 'text/xml', 'text/html'], + ['conneg/plugin/plugin.id', 'text/html', 'text/html'], // Alias with extension pointing to no extension/constant content-type. -// ['alias.html', '', 'text/html'], -// ['alias.html', '*/*', 'text/html'], -// ['alias.html', 'text/xml', 'text/html'], -// ['alias.html', 'text/html', 'text/html'], + ['alias.html', '', 'text/html'], + ['alias.html', '*/*', 'text/html'], + ['alias.html', 'text/xml', 'text/html'], + ['alias.html', 'text/html', 'text/html'], ]; foreach ($tests as $test) {