You are here

public function MockRouteProvider::getRouteByName in Drupal 8

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

File

core/modules/system/src/Tests/Routing/MockRouteProvider.php, line 45

Class

MockRouteProvider
Easily configurable mock route provider.

Namespace

Drupal\system\Tests\Routing

Code

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