You are here

protected function ConfigurationRoutes::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/ConfigurationRoutes.php, line 38

Class

ConfigurationRoutes
Registers routes for all configurable schemas.

Namespace

Drupal\graphql\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  $routes = new RouteCollection();
  foreach ($this->schemaManager
    ->getDefinitions() as $key => $definition) {
    if (empty($definition['uses_plugins'])) {
      continue;
    }
    $routes
      ->add("graphql.configuration.{$key}", new Route("{$definition['path']}/configure", [
      'schema' => $key,
      '_controller' => '\\Drupal\\graphql\\Controller\\ConfigurationController::configurationOverview',
      '_title' => 'Configuration',
    ], [
      '_admin_route' => 'TRUE',
    ]));
  }
  $collection
    ->addCollection($routes);
}