diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index dd9d57b..ac4b934 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -12,6 +12,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Path\AliasManagerInterface; +use Drupal\Core\Routing\MatchingRouteNotFoundException; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Template\Attribute; use Drupal\Core\Url; @@ -141,8 +142,13 @@ public function generate($text, $route_name, array $parameters = array(), array * {@inheritdoc} */ public function generateFromPath($text, $path, array $options = array()) { - $url = Url::createFromPath($path, $options); - return $this->generateFromUrl($text, $url); + try { + $url = Url::createFromPath($path, $options); + return $this->generateFromUrl($text, $url); + } + catch (MatchingRouteNotFoundException $e) { + return ""; + } } }