diff --git a/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php b/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php index 6a5527bdeb..70dd105742 100644 --- a/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php +++ b/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php @@ -113,6 +113,7 @@ public function generateFromRoute($name, $parameters = [], $options = [], $colle * {@inheritdoc} */ public function supports($name) { + @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Only string route names are supported. See https://www.drupal.org/node/3172303', E_USER_DEPRECATED); return $this->urlGenerator->supports($name); } @@ -120,6 +121,7 @@ public function supports($name) { * {@inheritdoc} */ public function getRouteDebugMessage($name, array $parameters = []) { + @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use the route name instead. See https://www.drupal.org/node/3172303', E_USER_DEPRECATED); return $this->urlGenerator->getRouteDebugMessage($name, $parameters); } diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index 255f144028..443a6e6fdc 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -432,6 +432,9 @@ protected function getRoute($name) { /** * Gets either the route name or a string based on the route object. * + * @param mixed $name + * A string route name, or a serializable object. + * * @return string * Either the route name, or a string that uniquely identifies the route. * @@ -453,7 +456,7 @@ private function getRouteStringIdentifier($name, array $parameters = []) { * {@inheritdoc} */ public function supports($name) { - @trigger_error(__METHOD__ . ' is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. Only string route names are supported.', E_USER_DEPRECATED); + @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Only string route names are supported. See https://www.drupal.org/node/3172303', E_USER_DEPRECATED); // Support a route object and any string as route name. return is_string($name) || $name instanceof SymfonyRoute; } @@ -462,16 +465,8 @@ public function supports($name) { * {@inheritdoc} */ public function getRouteDebugMessage($name, array $parameters = []) { - @trigger_error(__METHOD__ . ' is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. Use the route name instead.', E_USER_DEPRECATED); - if (is_scalar($name)) { - return $name; - } - - if ($name instanceof SymfonyRoute) { - return 'Route with pattern ' . $name->getPath(); - } - - return serialize($name); + @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use the route name instead. See https://www.drupal.org/node/3172303', E_USER_DEPRECATED); + return $this->getRouteStringIdentifier($name, $parameters); } } diff --git a/core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php b/core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php index 9cdaa41858..b5f99c7329 100644 --- a/core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php +++ b/core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php @@ -49,6 +49,7 @@ public function generateFromRoute($name, $parameters = [], $options = [], $colle * {@inheritdoc} */ public function supports($name) { + @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Only string route names are supported. See https://www.drupal.org/node/3172303', E_USER_DEPRECATED); throw new \Exception(); } @@ -56,6 +57,7 @@ public function supports($name) { * {@inheritdoc} */ public function getRouteDebugMessage($name, array $parameters = []) { + @trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use the route name instead. See https://www.drupal.org/node/3172303', E_USER_DEPRECATED); throw new \Exception(); } diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index 8f4a9ba339..744fbbc455 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -455,8 +455,8 @@ public function testBaseURLGeneration() { * Tests deprecated methods. * * @group legacy - * @expectedDeprecation Drupal\Core\Routing\UrlGenerator::getRouteDebugMessage is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. Use the route name instead. - * @expectedDeprecation Drupal\Core\Routing\UrlGenerator::supports is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. Only string route names are supported. + * @expectedDeprecation Drupal\Core\Routing\UrlGenerator::getRouteDebugMessage() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use the route name instead. See https://www.drupal.org/node/3172303 + * @expectedDeprecation Drupal\Core\Routing\UrlGenerator::supports() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Only string route names are supported. See https://www.drupal.org/node/3172303 */ public function testDeprecatedMethods() { $this->generator->getRouteDebugMessage('test');