class VoyagerRoutes in GraphQL 8.3
Registers graphql voyager routes for all schemas.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\graphql\Routing\VoyagerRoutes
Expanded class hierarchy of VoyagerRoutes
1 string reference to 'VoyagerRoutes'
1 service uses VoyagerRoutes
File
- src/
Routing/ VoyagerRoutes.php, line 13
Namespace
Drupal\graphql\RoutingView source
class VoyagerRoutes extends RouteSubscriberBase {
/**
* The graphql schema plugin manager.
*
* @var \Drupal\graphql\Plugin\SchemaPluginManager
*/
protected $schemaManager;
/**
* VoyagerRoutes constructor.
*
* @param \Drupal\graphql\Plugin\SchemaPluginManager $schemaManager
* The graphql schema plugin manager.
*/
public function __construct(SchemaPluginManager $schemaManager) {
$this->schemaManager = $schemaManager;
}
/**
* Alters existing routes for a specific collection.
*
* @param \Symfony\Component\Routing\RouteCollection $collection
* The route collection for adding routes.
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriberBase:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | 5 |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |
VoyagerRoutes:: |
protected | property | The graphql schema plugin manager. | |
VoyagerRoutes:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
VoyagerRoutes:: |
public | function | VoyagerRoutes constructor. |