ConfigurationRoutes.php in GraphQL 8.3
File
src/Routing/ConfigurationRoutes.php
View source
<?php
namespace Drupal\graphql\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Drupal\graphql\Plugin\SchemaPluginManager;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
class ConfigurationRoutes extends RouteSubscriberBase {
protected $schemaManager;
public function __construct(SchemaPluginManager $schemaManager) {
$this->schemaManager = $schemaManager;
}
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);
}
}