GraphQLConfigOverrides.php in GraphQL 8.3
File
src/Config/GraphQLConfigOverrides.php
View source
<?php
namespace Drupal\graphql\Config;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryOverrideInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\language\LanguageNegotiationMethodManager;
class GraphQLConfigOverrides implements ConfigFactoryOverrideInterface {
protected $baseStorage;
protected $negotiatorManager;
public function __construct(StorageInterface $storage, LanguageNegotiationMethodManager $negotiatorManager = NULL) {
$this->baseStorage = $storage;
$this->negotiatorManager = $negotiatorManager;
}
public function loadOverrides($names) {
if ($this->negotiatorManager && in_array('language.types', $names) && $this->negotiatorManager
->hasDefinition('language-graphql') && ($config = $this->baseStorage
->read('language.types'))) {
foreach (array_keys($config['negotiation']) as $type) {
$config['negotiation'][$type]['enabled']['language-graphql'] = -999;
asort($config['negotiation'][$type]['enabled']);
}
return [
'language.types' => $config,
];
}
return [];
}
public function getCacheSuffix() {
return 'graphql';
}
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
return NULL;
}
public function getCacheableMetadata($name) {
return new CacheableMetadata();
}
}