You are here

class EntityQueryMapQueryProvider in GraphQL 8.3

Hierarchy

Expanded class hierarchy of EntityQueryMapQueryProvider

1 string reference to 'EntityQueryMapQueryProvider'
graphql.services.yml in ./graphql.services.yml
graphql.services.yml
1 service uses EntityQueryMapQueryProvider
graphql.query_provider.query_map.entity in ./graphql.services.yml
Drupal\graphql\GraphQL\QueryProvider\EntityQueryMapQueryProvider

File

src/GraphQL/QueryProvider/EntityQueryMapQueryProvider.php, line 8

Namespace

Drupal\graphql\GraphQL\QueryProvider
View source
class EntityQueryMapQueryProvider implements QueryProviderInterface {

  /**
   * The entity type manager service.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * QueryProvider constructor.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager service.
   */
  public function __construct(EntityTypeManagerInterface $entityTypeManager) {
    $this->entityTypeManager = $entityTypeManager;
  }

  /**
   * {@inheritdoc}
   */
  public function getQuery($id, OperationParams $operation) {
    list($version, $id) = explode(':', $id);

    // Check that the id is properly formatted.
    if (empty($version) || empty($id)) {
      return NULL;
    }
    $storage = $this->entityTypeManager
      ->getStorage('graphql_query_map');

    /** @var \Drupal\graphql\Entity\QueryMapInterface $map */
    if ($map = $storage
      ->load($version)) {
      return $map
        ->getQuery($id);
    }
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityQueryMapQueryProvider::$entityTypeManager protected property The entity type manager service.
EntityQueryMapQueryProvider::getQuery public function Returns a query string given the query parameters. Overrides QueryProviderInterface::getQuery
EntityQueryMapQueryProvider::__construct public function QueryProvider constructor.