class QueryProvider in GraphQL 8.3
Hierarchy
- class \Drupal\graphql\GraphQL\QueryProvider\QueryProvider implements QueryProviderInterface
Expanded class hierarchy of QueryProvider
1 string reference to 'QueryProvider'
1 service uses QueryProvider
File
- src/
GraphQL/ QueryProvider/ QueryProvider.php, line 7
Namespace
Drupal\graphql\GraphQL\QueryProviderView source
class QueryProvider implements QueryProviderInterface {
/**
* Unsorted list of query providers nested and keyed by priority.
*
* @var \Drupal\graphql\GraphQL\QueryProvider\QueryProviderInterface[]
*/
protected $providers = [];
/**
* Sorted list of query providers.
*
* @var \Drupal\graphql\GraphQL\QueryProvider\QueryProviderInterface[]
*/
protected $sortedProviders;
/**
* {@inheritdoc}
*/
public function getQuery($id, OperationParams $operation) {
foreach ($this
->getSortedProviders() as $provider) {
if ($query = $provider
->getQuery($id, $operation)) {
return $query;
}
}
return NULL;
}
/**
* Adds a query provider.
*
* @param \Drupal\graphql\GraphQL\QueryProvider\QueryProviderInterface $provider
* The query provider to add.
* @param int $priority
* Priority of the query provider.
*/
public function addQueryProvider(QueryProviderInterface $provider, $priority = 0) {
$this->providers[$priority][] = $provider;
$this->sortedProviders = NULL;
}
/**
* Returns the sorted array of query providers.
*
* @return \Drupal\graphql\GraphQL\QueryProvider\QueryProviderInterface[]
* An array of query provider objects.
*/
protected function getSortedProviders() {
if (!isset($this->sortedProviders)) {
krsort($this->providers);
$this->sortedProviders = [];
foreach ($this->providers as $providers) {
$this->sortedProviders = array_merge($this->sortedProviders, $providers);
}
}
return $this->sortedProviders;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
QueryProvider:: |
protected | property | Unsorted list of query providers nested and keyed by priority. | |
QueryProvider:: |
protected | property | Sorted list of query providers. | |
QueryProvider:: |
public | function | Adds a query provider. | |
QueryProvider:: |
public | function |
Returns a query string given the query parameters. Overrides QueryProviderInterface:: |
|
QueryProvider:: |
protected | function | Returns the sorted array of query providers. |