ContextRepository.php in GraphQL 8.3
File
src/GraphQL/Context/ContextRepository.php
View source
<?php
namespace Drupal\graphql\GraphQL\Context;
use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\Plugin\Context\ContextRepositoryInterface;
class ContextRepository implements ContextRepositoryInterface {
protected $contextProviders = [];
public function addContextProvider(ContextProviderInterface $contextProvider) {
$this->contextProviders[] = $contextProvider;
}
public function getRuntimeContexts(array $contextIds) {
$contexts = [];
foreach ($this->contextProviders as $contextProvider) {
foreach ($contextProvider
->getRuntimeContexts($contextIds) as $id => $context) {
$contexts[$id] = $context;
}
}
return $contexts;
}
public function getAvailableContexts() {
$contexts = [];
foreach ($this->contextProviders as $contextProvider) {
foreach ($contextProvider
->getAvailableContexts() as $id => $context) {
$contexts[$id] = $context;
}
}
return $contexts;
}
}