Issue #3293284 by catch: Throw an exception when Router::generate() is called
parent
2ba1d67a41
commit
c4edefd1d7
|
@ -311,11 +311,15 @@ class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* This method is intentionally not implemented. Use
|
||||||
|
* Drupal\Core\Url instead.
|
||||||
|
*
|
||||||
|
* @see https://www.drupal.org/node/2820197
|
||||||
|
*
|
||||||
|
* @throws \BadMethodCallException
|
||||||
*/
|
*/
|
||||||
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH): string {
|
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH): string {
|
||||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:8.3.0 and will throw an exception from drupal:10.0.0. Use the \Drupal\Core\Url object instead. See https://www.drupal.org/node/2820197', E_USER_DEPRECATED);
|
throw new \BadMethodCallException(__METHOD__ . '() is not supported. Use the \Drupal\Core\Url object instead. See https://www.drupal.org/node/2820197');
|
||||||
return $this->urlGenerator->generate($name, $parameters, $referenceType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,13 @@ use Prophecy\Argument;
|
||||||
* @group Routing
|
* @group Routing
|
||||||
* @group legacy
|
* @group legacy
|
||||||
*/
|
*/
|
||||||
class RouterLegacyTest extends UnitTestCase {
|
class RouterUnsupportedTest extends UnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::generate
|
* @covers ::generate
|
||||||
*/
|
*/
|
||||||
public function testGenerateDeprecated() {
|
public function testGenerateUnsupported() {
|
||||||
$this->expectDeprecation('Drupal\Core\Routing\Router::generate() is deprecated in drupal:8.3.0 and will throw an exception from drupal:10.0.0. Use the \Drupal\Core\Url object instead. See https://www.drupal.org/node/2820197');
|
$this->expectException(\BadMethodCallException::class);
|
||||||
$route_provider = $this->prophesize(RouteProviderInterface::class);
|
$route_provider = $this->prophesize(RouteProviderInterface::class);
|
||||||
$current_path_stack = $this->prophesize(CurrentPathStack::class);
|
$current_path_stack = $this->prophesize(CurrentPathStack::class);
|
||||||
$url_generator = $this->prophesize(UrlGeneratorInterface::class);
|
$url_generator = $this->prophesize(UrlGeneratorInterface::class);
|
||||||
|
@ -30,7 +30,7 @@ class RouterLegacyTest extends UnitTestCase {
|
||||||
->generate($route_name, Argument::any(), Argument::any())
|
->generate($route_name, Argument::any(), Argument::any())
|
||||||
->willReturn($route_path);
|
->willReturn($route_path);
|
||||||
$router = new Router($route_provider->reveal(), $current_path_stack->reveal(), $url_generator->reveal());
|
$router = new Router($route_provider->reveal(), $current_path_stack->reveal(), $url_generator->reveal());
|
||||||
$this->assertEquals($route_path, $router->generate($route_name));
|
$router->generate($route_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue