protected function UrlGenerator::getRoute

protected UrlGenerator::getRoute($name)

Find the route using the provided route name.

Parameters

string|\Symfony\Component\Routing\Route $name: The route name or a route object.

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.

See also

\Drupal\Core\Routing\RouteProviderInterface

File

core/lib/Drupal/Core/Routing/UrlGenerator.php, line 421

Class

UrlGenerator
Generates URLs from route names and parameters.

Namespace

Drupal\Core\Routing

Code

protected function getRoute($name) {
  if ($name instanceof SymfonyRoute) {
    $route = $name;
  }
  elseif (NULL === $route = clone $this->provider->getRouteByName($name)) {
    throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
  }
  return $route;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Routing!UrlGenerator.php/function/UrlGenerator::getRoute/8.1.x