Issues (645)

src/Routing/VoyagerRoutes.php (3 issues)

Labels
Severity
1
<?php
2
3
namespace Drupal\graphql\Routing;
4
5
use Drupal\Core\Routing\RouteSubscriberBase;
0 ignored issues
show
The type Drupal\Core\Routing\RouteSubscriberBase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Drupal\graphql\Plugin\SchemaPluginManager;
7
use Symfony\Component\Routing\Route;
0 ignored issues
show
The type Symfony\Component\Routing\Route was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\Routing\RouteCollection;
0 ignored issues
show
The type Symfony\Component\Routing\RouteCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
/**
11
 * Registers graphql voyager routes for all schemas.
12
 */
13
class VoyagerRoutes extends RouteSubscriberBase {
14
15
  /**
16
   * The graphql schema plugin manager.
17
   *
18
   * @var \Drupal\graphql\Plugin\SchemaPluginManager
19
   */
20
  protected $schemaManager;
21
22
  /**
23
   * VoyagerRoutes constructor.
24
   *
25
   * @param \Drupal\graphql\Plugin\SchemaPluginManager $schemaManager
26
   *   The graphql schema plugin manager.
27
   */
28
  public function __construct(SchemaPluginManager $schemaManager) {
29
    $this->schemaManager = $schemaManager;
30
  }
31
32
  /**
33
   * Alters existing routes for a specific collection.
34
   *
35
   * @param \Symfony\Component\Routing\RouteCollection $collection
36
   *   The route collection for adding routes.
37
   */
38
  protected function alterRoutes(RouteCollection $collection) {
39
    $routes = new RouteCollection();
40
41
    foreach ($this->schemaManager->getDefinitions() as $key => $definition) {
42
      $routes->add("graphql.voyager.$key", new Route("{$definition['path']}/voyager", [
43
        'schema' => $key,
44
        '_controller' => '\Drupal\graphql\Controller\VoyagerController::viewVoyager',
45
        '_title' => 'GraphQL Voyager',
46
      ], [
47
        '_permission' => 'use graphql voyager',
48
      ], [
49
        '_admin_route' => 'TRUE',
50
      ]));
51
    }
52
53
    $collection->addCollection($routes);
54
  }
55
56
}
57