public function RouteProvider::getRoutesPaged

public RouteProvider::getRoutesPaged($offset, $length = NULL)

Find an amount of routes with an offset and possible a limit.

In case you want to iterate over all routes, you want to avoid to load all routes at once.

Parameters

int $offset: The sequence will start with that offset in the list of all routes.

int $length [optional]: The sequence will have that many routes in it. If no length is specified all routes are returned.

Return value

\Symfony\Component\Routing\Route[] Routes keyed by the route name.

Overrides PagedRouteProviderInterface::getRoutesPaged

File

core/lib/Drupal/Core/Routing/RouteProvider.php, line 399

Class

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

Namespace

Drupal\Core\Routing

Code

public function getRoutesPaged($offset, $length = NULL) {
  $select = $this->connection->select($this->tableName, 'router')
    ->fields('router', ['name', 'route']);

  if (isset($length)) {
    $select->range($offset, $length);
  }

  $routes = $select->execute()->fetchAllKeyed();

  $result = [];
  foreach ($routes as $name => $route) {
    $result[$name] = unserialize($route);
  }

  return $result;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Routing!RouteProvider.php/function/RouteProvider::getRoutesPaged/8.1.x