You are here

protected function VoyagerRoutes::alterRoutes in GraphQL 8.3

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/VoyagerRoutes.php, line 38

Class

VoyagerRoutes
Registers graphql voyager routes for all schemas.

Namespace

Drupal\graphql\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  $routes = new RouteCollection();
  foreach ($this->schemaManager
    ->getDefinitions() as $key => $definition) {
    $routes
      ->add("graphql.voyager.{$key}", new Route("{$definition['path']}/voyager", [
      'schema' => $key,
      '_controller' => '\\Drupal\\graphql\\Controller\\VoyagerController::viewVoyager',
      '_title' => 'GraphQL Voyager',
    ], [
      '_permission' => 'use graphql voyager',
    ], [
      '_admin_route' => 'TRUE',
    ]));
  }
  $collection
    ->addCollection($routes);
}