You are here

public function RouteProvider::getRouteByName in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Routing/RouteProvider.php \Drupal\Core\Routing\RouteProvider::getRouteByName()

Find the route using the provided route name (and parameters).

Parameters

string $name: The route name to fetch

Return value

\Symfony\Component\Routing\Route The found route.

Throws

\Symfony\Component\Routing\Exception\RouteNotFoundException Thrown if there is no route with that name in this repository.

Overrides RouteProviderInterface::getRouteByName

File

core/lib/Drupal/Core/Routing/RouteProvider.php, line 188
Contains \Drupal\Core\Routing\RouteProvider.

Class

RouteProvider
A Route Provider front-end for all Drupal-stored routes.

Namespace

Drupal\Core\Routing

Code

public function getRouteByName($name) {
  $routes = $this
    ->getRoutesByNames(array(
    $name,
  ));
  if (empty($routes)) {
    throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
  }
  return reset($routes);
}