You are here

public function MockRouteProvider::getRouteByName in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Routing/MockRouteProvider.php \Drupal\system\Tests\Routing\MockRouteProvider::getRouteByName()

Find the route using the provided route name.

Parameters

string $name The route name to fetch.:

Return value

Route

Throws

RouteNotFoundException If there is no route with that name in this repository

Overrides RouteProviderInterface::getRouteByName

File

core/modules/system/src/Tests/Routing/MockRouteProvider.php, line 50
Contains \Drupal\system\Tests\Routing\MockRouteProvider.

Class

MockRouteProvider
Easily configurable mock route provider.

Namespace

Drupal\system\Tests\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);
}