Issue #3443492 by smustgrave, quietone, mikelutz: Remove deprecated code from lib/Routing
parent
9a391c4bfb
commit
c21992c1b0
|
@ -17,13 +17,6 @@ use Drupal\Core\Database\Connection;
|
|||
*/
|
||||
class MatcherDumper implements MatcherDumperInterface {
|
||||
|
||||
/**
|
||||
* The database connection to which to dump route information.
|
||||
*
|
||||
* @var \Drupal\Core\Database\Connection
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* The routes to be dumped.
|
||||
*
|
||||
|
@ -31,12 +24,6 @@ class MatcherDumper implements MatcherDumperInterface {
|
|||
*/
|
||||
protected $routes;
|
||||
|
||||
/**
|
||||
* The state.
|
||||
*
|
||||
* @var \Drupal\Core\State\StateInterface
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The name of the SQL table to which to dump the routes.
|
||||
|
@ -45,13 +32,6 @@ class MatcherDumper implements MatcherDumperInterface {
|
|||
*/
|
||||
protected $tableName;
|
||||
|
||||
/**
|
||||
* The logger.
|
||||
*
|
||||
* @var \Psr\Log\LoggerInterface
|
||||
*/
|
||||
protected LoggerInterface $logger;
|
||||
|
||||
/**
|
||||
* Construct the MatcherDumper.
|
||||
*
|
||||
|
@ -60,22 +40,17 @@ class MatcherDumper implements MatcherDumperInterface {
|
|||
* information.
|
||||
* @param \Drupal\Core\State\StateInterface $state
|
||||
* The state.
|
||||
* @param \Psr\Log\LoggerInterface|null $logger
|
||||
* @param \Psr\Log\LoggerInterface $logger
|
||||
* The logger.
|
||||
* @param string $table
|
||||
* (optional) The table to store the route info in. Defaults to 'router'.
|
||||
*/
|
||||
public function __construct(Connection $connection, StateInterface $state, LoggerInterface|string|null $logger = NULL, $table = 'router') {
|
||||
$this->connection = $connection;
|
||||
$this->state = $state;
|
||||
if (is_string($logger) || is_null($logger)) {
|
||||
@trigger_error('Calling ' . __METHOD__ . '() without the $logger argument is deprecated in drupal:10.1.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/2932520', E_USER_DEPRECATED);
|
||||
$this->logger = \Drupal::service('logger.channel.router');
|
||||
$this->tableName = $logger;
|
||||
}
|
||||
else {
|
||||
$this->logger = $logger;
|
||||
}
|
||||
public function __construct(
|
||||
protected Connection $connection,
|
||||
protected StateInterface $state,
|
||||
protected LoggerInterface $logger,
|
||||
protected $table = 'router',
|
||||
) {
|
||||
if (is_null($this->tableName)) {
|
||||
$this->tableName = $table;
|
||||
}
|
||||
|
|
|
@ -17,20 +17,6 @@ use Symfony\Component\Routing\Route;
|
|||
*/
|
||||
class RoutePreloader implements EventSubscriberInterface {
|
||||
|
||||
/**
|
||||
* The route provider.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RouteProviderInterface|\Drupal\Core\Routing\PreloadableRouteProviderInterface
|
||||
*/
|
||||
protected $routeProvider;
|
||||
|
||||
/**
|
||||
* The state key value store.
|
||||
*
|
||||
* @var \Drupal\Core\State\StateInterface
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Contains the non-admin routes while rebuilding the routes.
|
||||
*
|
||||
|
@ -41,17 +27,15 @@ class RoutePreloader implements EventSubscriberInterface {
|
|||
/**
|
||||
* Constructs a new RoutePreloader.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
|
||||
* @param \Drupal\Core\Routing\RouteProviderInterface $routeProvider
|
||||
* The route provider.
|
||||
* @param \Drupal\Core\State\StateInterface $state
|
||||
* The state key value store.
|
||||
*/
|
||||
public function __construct(RouteProviderInterface $route_provider, StateInterface $state) {
|
||||
$this->routeProvider = $route_provider;
|
||||
$this->state = $state;
|
||||
if (func_num_args() > 2) {
|
||||
@trigger_error(sprintf('Passing a cache bin to %s is deprecated in drupal:10.3.0 and will be removed before drupal:11.0.0. Caching is now managed by the state service. See https://www.drupal.org/node/3177901', __METHOD__), E_USER_DEPRECATED);
|
||||
}
|
||||
public function __construct(
|
||||
protected RouteProviderInterface $routeProvider,
|
||||
protected StateInterface $state,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\KernelTests\Core\Routing;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Routing\MatcherDumper;
|
||||
use Drupal\Core\State\State;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Tests deprecations in MatcherDumper.
|
||||
*
|
||||
* @group Routing
|
||||
* @group legacy
|
||||
* @coversDefaultClass \Drupal\Core\Routing\MatcherDumper
|
||||
*/
|
||||
class LegacyMatcherDumperTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* The connection.
|
||||
*
|
||||
* @var \Drupal\Core\Database\Connection
|
||||
*/
|
||||
protected Connection $connection;
|
||||
|
||||
/**
|
||||
* The state.
|
||||
*
|
||||
* @var \Drupal\Core\State\State
|
||||
*/
|
||||
protected State $state;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp():void {
|
||||
parent::setUp();
|
||||
$this->connection = $this->createMock(Connection::class);
|
||||
$this->state = $this->createMock(State::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the constructor deprecations.
|
||||
*/
|
||||
public function testConstructorDeprecationNoLogger() {
|
||||
$this->expectDeprecation('Calling Drupal\Core\Routing\MatcherDumper::__construct() without the $logger argument is deprecated in drupal:10.1.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/2932520');
|
||||
$dumper = new MatcherDumper($this->connection, $this->state);
|
||||
$this->assertNotNull($dumper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the constructor deprecations.
|
||||
*/
|
||||
public function testConstructorDeprecationWithLegacyTableNameParam() {
|
||||
$this->expectDeprecation('Calling Drupal\Core\Routing\MatcherDumper::__construct() without the $logger argument is deprecated in drupal:10.1.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/2932520');
|
||||
$dumper = new MatcherDumper($this->connection, $this->state, 'foo');
|
||||
$this->assertNotNull($dumper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the constructor deprecations.
|
||||
*/
|
||||
public function testConstructorDeprecationWithLogger() {
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$dumper = new MatcherDumper($this->connection, $this->state, $logger);
|
||||
$this->assertNotNull($dumper);
|
||||
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$dumper = new MatcherDumper($this->connection, $this->state, $logger, 'foo');
|
||||
$this->assertNotNull($dumper);
|
||||
}
|
||||
|
||||
}
|
|
@ -176,12 +176,4 @@ class RoutePreloaderTest extends UnitTestCase {
|
|||
$this->preloader->onRequest($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testConstructorDeprecation() {
|
||||
$this->expectDeprecation('Passing a cache bin to Drupal\Core\Routing\RoutePreloader::__construct is deprecated in drupal:10.3.0 and will be removed before drupal:11.0.0. Caching is now managed by the state service. See https://www.drupal.org/node/3177901');
|
||||
new RoutePreloader($this->routeProvider, $this->state, $this->createMock('Drupal\Core\Cache\CacheBackendInterface'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue