class ContextRepository in GraphQL 8.3
Non-lazy un-optimized context repository.
Intermediate solution for graphql requests that change context within one request and would confuse the LazyContextBuilder.
Hierarchy
- class \Drupal\graphql\GraphQL\Context\ContextRepository implements ContextRepositoryInterface
Expanded class hierarchy of ContextRepository
1 string reference to 'ContextRepository'
1 service uses ContextRepository
File
- src/
GraphQL/ Context/ ContextRepository.php, line 14
Namespace
Drupal\graphql\GraphQL\ContextView source
class ContextRepository implements ContextRepositoryInterface {
/**
* The list of content providers.
*
* @var \Drupal\Core\Plugin\Context\ContextProviderInterface[]
*/
protected $contextProviders = [];
/**
* Add a context provider.
*
* @param \Drupal\Core\Plugin\Context\ContextProviderInterface $contextProvider
* The context provider to add.
*/
public function addContextProvider(ContextProviderInterface $contextProvider) {
$this->contextProviders[] = $contextProvider;
}
/**
* {@inheritdoc}
*/
public function getRuntimeContexts(array $contextIds) {
$contexts = [];
foreach ($this->contextProviders as $contextProvider) {
foreach ($contextProvider
->getRuntimeContexts($contextIds) as $id => $context) {
$contexts[$id] = $context;
}
}
return $contexts;
}
/**
* {@inheritdoc}
*/
public function getAvailableContexts() {
$contexts = [];
foreach ($this->contextProviders as $contextProvider) {
foreach ($contextProvider
->getAvailableContexts() as $id => $context) {
$contexts[$id] = $context;
}
}
return $contexts;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContextRepository:: |
protected | property | The list of content providers. | |
ContextRepository:: |
public | function | Add a context provider. | |
ContextRepository:: |
public | function |
Gets all available contexts for the purposes of configuration. Overrides ContextRepositoryInterface:: |
|
ContextRepository:: |
public | function |
Gets runtime context values for the given context IDs. Overrides ContextRepositoryInterface:: |