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 {
|
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.
|
* The routes to be dumped.
|
||||||
*
|
*
|
||||||
|
@ -31,12 +24,6 @@ class MatcherDumper implements MatcherDumperInterface {
|
||||||
*/
|
*/
|
||||||
protected $routes;
|
protected $routes;
|
||||||
|
|
||||||
/**
|
|
||||||
* The state.
|
|
||||||
*
|
|
||||||
* @var \Drupal\Core\State\StateInterface
|
|
||||||
*/
|
|
||||||
protected $state;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the SQL table to which to dump the routes.
|
* The name of the SQL table to which to dump the routes.
|
||||||
|
@ -45,13 +32,6 @@ class MatcherDumper implements MatcherDumperInterface {
|
||||||
*/
|
*/
|
||||||
protected $tableName;
|
protected $tableName;
|
||||||
|
|
||||||
/**
|
|
||||||
* The logger.
|
|
||||||
*
|
|
||||||
* @var \Psr\Log\LoggerInterface
|
|
||||||
*/
|
|
||||||
protected LoggerInterface $logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the MatcherDumper.
|
* Construct the MatcherDumper.
|
||||||
*
|
*
|
||||||
|
@ -60,22 +40,17 @@ class MatcherDumper implements MatcherDumperInterface {
|
||||||
* information.
|
* information.
|
||||||
* @param \Drupal\Core\State\StateInterface $state
|
* @param \Drupal\Core\State\StateInterface $state
|
||||||
* The state.
|
* The state.
|
||||||
* @param \Psr\Log\LoggerInterface|null $logger
|
* @param \Psr\Log\LoggerInterface $logger
|
||||||
* The logger.
|
* The logger.
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* (optional) The table to store the route info in. Defaults to 'router'.
|
* (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') {
|
public function __construct(
|
||||||
$this->connection = $connection;
|
protected Connection $connection,
|
||||||
$this->state = $state;
|
protected StateInterface $state,
|
||||||
if (is_string($logger) || is_null($logger)) {
|
protected LoggerInterface $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);
|
protected $table = 'router',
|
||||||
$this->logger = \Drupal::service('logger.channel.router');
|
) {
|
||||||
$this->tableName = $logger;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->logger = $logger;
|
|
||||||
}
|
|
||||||
if (is_null($this->tableName)) {
|
if (is_null($this->tableName)) {
|
||||||
$this->tableName = $table;
|
$this->tableName = $table;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,20 +17,6 @@ use Symfony\Component\Routing\Route;
|
||||||
*/
|
*/
|
||||||
class RoutePreloader implements EventSubscriberInterface {
|
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.
|
* Contains the non-admin routes while rebuilding the routes.
|
||||||
*
|
*
|
||||||
|
@ -41,17 +27,15 @@ class RoutePreloader implements EventSubscriberInterface {
|
||||||
/**
|
/**
|
||||||
* Constructs a new RoutePreloader.
|
* Constructs a new RoutePreloader.
|
||||||
*
|
*
|
||||||
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
|
* @param \Drupal\Core\Routing\RouteProviderInterface $routeProvider
|
||||||
* The route provider.
|
* The route provider.
|
||||||
* @param \Drupal\Core\State\StateInterface $state
|
* @param \Drupal\Core\State\StateInterface $state
|
||||||
* The state key value store.
|
* The state key value store.
|
||||||
*/
|
*/
|
||||||
public function __construct(RouteProviderInterface $route_provider, StateInterface $state) {
|
public function __construct(
|
||||||
$this->routeProvider = $route_provider;
|
protected RouteProviderInterface $routeProvider,
|
||||||
$this->state = $state;
|
protected StateInterface $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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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);
|
$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