You are here

public function MockRouteProvider::getRoutesByNames 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::getRoutesByNames()

Find many routes by their names using the provided list of names.

Note that this method may not throw an exception if some of the routes are not found or are not actually Route instances. It will just return the list of those Route instances it found.

This method exists in order to allow performance optimizations. The simple implementation could be to just repeatedly call $this->getRouteByName() while catching and ignoring eventual exceptions.

If $names is null, this method SHOULD return a collection of all routes known to this provider. If there are many routes to be expected, usage of a lazy loading collection is recommended. A provider MAY only return a subset of routes to e.g. support paging or other concepts, but be aware that the DynamicRouter will only call this method once per DynamicRouter::getRouteCollection() call.

Parameters

array|null $names The list of names to retrieve, In case of null,: the provider will determine what routes to return.

Return value

Route[] Iterable list with the keys being the names from the $names array.

Overrides RouteProviderInterface::getRoutesByNames

1 call to MockRouteProvider::getRoutesByNames()
MockRouteProvider::getRouteByName in core/modules/system/src/Tests/Routing/MockRouteProvider.php
Find the route using the provided route name.

File

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

Class

MockRouteProvider
Easily configurable mock route provider.

Namespace

Drupal\system\Tests\Routing

Code

public function getRoutesByNames($names) {
  $routes = array();
  foreach ($names as $name) {
    $routes[] = $this->routes
      ->get($name);
  }
  return $routes;
}