function UrlGenerator::getRoute

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Routing/UrlGenerator.php \Drupal\Core\Routing\UrlGenerator::getRoute()

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 427

Class

UrlGenerator
Generates URLs from route names and parameters.

Namespace

Drupal\Core\Routing

Code

protected function getRoute($name) {
  if ($name instanceof SymfonyRoute) {
    $route = $name;
  }
  else {
    $route = clone $this->provider
      ->getRouteByName($name);
  }
  return $route;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.