From 7454e5dfe09280208c43f45c024b4d22ed8f204f Mon Sep 17 00:00:00 2001 From: Dave Long Date: Sat, 2 Mar 2024 22:55:25 +0000 Subject: [PATCH] Issue #3347710 by andypost: [11.x] Remove deprecated non_lazy_route_enhancer and non_lazy_route_filter --- core/core.services.yml | 2 -- core/lib/Drupal/Core/Routing/Router.php | 32 ------------------- .../Core/Routing/RouterUnsupportedTest.php | 27 ---------------- 3 files changed, 61 deletions(-) diff --git a/core/core.services.yml b/core/core.services.yml index 4c35a65395d..447a0f9a18f 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1081,9 +1081,7 @@ services: class: \Drupal\Core\Routing\Router arguments: ['@router.route_provider', '@path.current', '@url_generator'] tags: - - { name: service_collector, tag: non_lazy_route_enhancer, call: addDeprecatedRouteEnhancer } - { name: service_collector, tag: route_enhancer, call: addRouteEnhancer } - - { name: service_collector, tag: non_lazy_route_filter, call: addDeprecatedRouteFilter } - { name: service_collector, tag: route_filter, call: addRouteFilter } calls: - [setContext, ['@router.request_context']] diff --git a/core/lib/Drupal/Core/Routing/Router.php b/core/lib/Drupal/Core/Routing/Router.php index bef84e9be84..369424d9081 100644 --- a/core/lib/Drupal/Core/Routing/Router.php +++ b/core/lib/Drupal/Core/Routing/Router.php @@ -84,22 +84,6 @@ class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterf $this->filters[] = $route_filter; } - /** - * Adds a deprecated route filter. - * - * @param \Drupal\Core\Routing\FilterInterface $route_filter - * The route filter. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * route_filter instead. - * - * @see https://www.drupal.org/node/2894934 - */ - public function addDeprecatedRouteFilter(FilterInterface $route_filter) { - @trigger_error('non_lazy_route_filter is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use route_filter instead. See https://www.drupal.org/node/2894934', E_USER_DEPRECATED); - $this->filters[] = $route_filter; - } - /** * Adds a route enhancer. * @@ -110,22 +94,6 @@ class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterf $this->enhancers[] = $route_enhancer; } - /** - * Adds a deprecated route enhancer. - * - * @param \Drupal\Core\Routing\EnhancerInterface $route_enhancer - * The route enhancer. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * route_enhancer instead. - * - * @see https://www.drupal.org/node/2894934 - */ - public function addDeprecatedRouteEnhancer(EnhancerInterface $route_enhancer) { - @trigger_error('non_lazy_route_enhancer is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use route_enhancer instead. See https://www.drupal.org/node/2894934', E_USER_DEPRECATED); - $this->enhancers[] = $route_enhancer; - } - /** * {@inheritdoc} */ diff --git a/core/tests/Drupal/Tests/Core/Routing/RouterUnsupportedTest.php b/core/tests/Drupal/Tests/Core/Routing/RouterUnsupportedTest.php index a0368ea80d0..cc306b0812e 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouterUnsupportedTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouterUnsupportedTest.php @@ -5,8 +5,6 @@ declare(strict_types=1); namespace Drupal\Tests\Core\Routing; use Drupal\Core\Path\CurrentPathStack; -use Drupal\Core\Routing\EnhancerInterface; -use Drupal\Core\Routing\FilterInterface; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Routing\Router; use Drupal\Core\Routing\UrlGeneratorInterface; @@ -37,29 +35,4 @@ class RouterUnsupportedTest extends UnitTestCase { $router->generate($route_name); } - /** - * @covers ::addDeprecatedRouteFilter - * @covers ::addDeprecatedRouteEnhancer - */ - public function testDeprecatedAdd() { - // Test needs access to router's protected properties. - $filters = new \ReflectionProperty(Router::class, 'filters'); - $enhancers = new \ReflectionProperty(Router::class, 'enhancers'); - - $route_provider = $this->prophesize(RouteProviderInterface::class); - $current_path_stack = $this->prophesize(CurrentPathStack::class); - $url_generator = $this->prophesize(UrlGeneratorInterface::class); - $router = new Router($route_provider->reveal(), $current_path_stack->reveal(), $url_generator->reveal()); - - $this->expectDeprecation('non_lazy_route_filter is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use route_filter instead. See https://www.drupal.org/node/2894934'); - $filter = $this->prophesize(FilterInterface::class)->reveal(); - $router->addDeprecatedRouteFilter($filter); - $this->assertSame($filter, $filters->getValue($router)[0]); - - $this->expectDeprecation('non_lazy_route_enhancer is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use route_enhancer instead. See https://www.drupal.org/node/2894934'); - $enhancer = $this->prophesize(EnhancerInterface::class)->reveal(); - $router->addDeprecatedRouteEnhancer($enhancer); - $this->assertSame($enhancer, $enhancers->getValue($router)[0]); - } - }