Issues (645)

QueryProvider/EntityQueryMapQueryProvider.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Drupal\graphql\GraphQL\QueryProvider;
4
5
use Drupal\Core\Entity\EntityTypeManagerInterface;
0 ignored issues
show
The type Drupal\Core\Entity\EntityTypeManagerInterface 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 GraphQL\Server\OperationParams;
7
8
class EntityQueryMapQueryProvider implements QueryProviderInterface {
9
10
  /**
11
   * The entity type manager service.
12
   *
13
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
14
   */
15
  protected $entityTypeManager;
16
17
  /**
18
   * QueryProvider constructor.
19
   *
20
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
21
   *   The entity type manager service.
22
   */
23
  public function __construct(EntityTypeManagerInterface $entityTypeManager) {
24
    $this->entityTypeManager = $entityTypeManager;
25
  }
26
27
  /**
28
   * {@inheritdoc}
29
   */
30
  public function getQuery($id, OperationParams $operation) {
31
    list($version, $id) = explode(':', $id);
32
33
    // Check that the id is properly formatted.
34
    if (empty($version) || empty($id)) {
35
      return NULL;
36
    }
37
38
    $storage = $this->entityTypeManager->getStorage('graphql_query_map');
39
    /** @var \Drupal\graphql\Entity\QueryMapInterface $map */
40
    if ($map = $storage->load($version)) {
41
      return $map->getQuery($id);
42
    }
43
44
    return NULL;
45
  }
46
}
47