Skip to content
Snippets Groups Projects

Handle fatal error in UrlGenerator:: getRoute()

@@ -12,6 +12,7 @@
use Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
/**
* Generates URLs from route names and parameters.
@@ -447,8 +448,11 @@ protected function processRoute(string $name, SymfonyRoute $route, array &$param
* @see \Drupal\Core\Routing\RouteProviderInterface
*/
protected function getRoute(string $name) {
$route = clone $this->provider->getRouteByName($name);
return $route;
$route = $this->provider->getRouteByName($name);
if ($route) {
return clone $route;
}
throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
}
}
Loading