You are here

public function RouteProvider::getAllRoutes in Drupal 10

Same name in this branch
  1. 10 core/tests/Drupal/KernelTests/RouteProvider.php \Drupal\KernelTests\RouteProvider::getAllRoutes()
  2. 10 core/lib/Drupal/Core/Routing/RouteProvider.php \Drupal\Core\Routing\RouteProvider::getAllRoutes()
Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Routing/RouteProvider.php \Drupal\Core\Routing\RouteProvider::getAllRoutes()
  2. 9 core/lib/Drupal/Core/Routing/RouteProvider.php \Drupal\Core\Routing\RouteProvider::getAllRoutes()

Returns all the routes on the system.

Usage of this method is discouraged for performance reasons. If possible, use RouteProviderInterface::getRoutesByNames() or RouteProviderInterface::getRoutesByPattern() instead.

Return value

\Symfony\Component\Routing\Route[] An iterator of routes keyed by route name.

Overrides RouteProviderInterface::getAllRoutes

File

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

Class

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

Namespace

Drupal\Core\Routing

Code

public function getAllRoutes() {
  $select = $this->connection
    ->select($this->tableName, 'router')
    ->fields('router', [
    'name',
    'route',
  ]);
  $routes = $select
    ->execute()
    ->fetchAllKeyed();
  $result = [];
  foreach ($routes as $name => $route) {
    $result[$name] = unserialize($route);
  }
  $array_object = new \ArrayObject($result);
  return $array_object
    ->getIterator();
}