public function RouteProvider::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. It will just return the list of those routes it found.

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

Parameters

array $names: The list of names to retrieve.

array $parameters: The parameters as they are passed to the UrlGeneratorInterface::generate call. (Only one array, not one for each entry in $names).

Return value

\Symfony\Component\Routing\Route[] Iterable thing with the keys the names of the $names argument.

Overrides RouteProviderInterface::getRoutesByNames

1 call to RouteProvider::getRoutesByNames()
RouteProvider::getRouteByName in drupal/core/lib/Drupal/Core/Routing/RouteProvider.php
Find the route using the provided route name (and parameters).

File

drupal/core/lib/Drupal/Core/Routing/RouteProvider.php, line 171
Contains Drupal\Core\Routing\RouteProvider.

Class

RouteProvider
A Route Provider front-end for all Drupal-stored routes.

Namespace

Drupal\Core\Routing

Code

public function getRoutesByNames($names, $parameters = array()) {
  if (empty($names)) {
    throw new \InvalidArgumentException('You must specify the route names to load');
  }
  $routes_to_load = array_diff($names, array_keys($this->routes));
  if ($routes_to_load) {
    $result = $this->connection
      ->query('SELECT name, route FROM {' . $this->connection
      ->escapeTable($this->tableName) . '} WHERE name IN (:names)', array(
      ':names' => $routes_to_load,
    ));
    $routes = $result
      ->fetchAllKeyed();
    $return = array();
    foreach ($routes as $name => $route) {
      $this->routes[$name] = unserialize($route);
    }
  }
  return array_intersect_key($this->routes, array_flip($names));
}