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;
}
doc_Drupal
2016-10-29 09:39:18
Comments
Leave a Comment

Please login to continue.