You are here

public function LazyRouteCollection::get in Drupal 9

Gets a route by name.

Parameters

string $name: The route name

Return value

\Symfony\Component\Routing\Route|null A Route instance or null when not found

File

core/lib/Drupal/Core/Routing/LazyRouteCollection.php, line 59

Class

LazyRouteCollection

Namespace

Drupal\Core\Routing

Code

public function get($name) {
  try {
    return $this->provider
      ->getRouteByName($name);
  } catch (RouteNotFoundException $e) {
    return;
  }
}