You are here

class GraphQLConfigOverrides in GraphQL 8.3

GraphQL config overrides.

Enforce the GraphQL language negotiation always to be on top.

Hierarchy

Expanded class hierarchy of GraphQLConfigOverrides

1 string reference to 'GraphQLConfigOverrides'
graphql.services.yml in ./graphql.services.yml
graphql.services.yml
1 service uses GraphQLConfigOverrides
graphql.config_factory_override in ./graphql.services.yml
Drupal\graphql\Config\GraphQLConfigOverrides

File

src/Config/GraphQLConfigOverrides.php, line 15

Namespace

Drupal\graphql\Config
View source
class GraphQLConfigOverrides implements ConfigFactoryOverrideInterface {

  /**
   * The config storage service.
   *
   * @var \Drupal\Core\Config\StorageInterface
   */
  protected $baseStorage;

  /**
   * The negotiator manager service.
   *
   * @var \Drupal\language\LanguageNegotiationMethodManager|null
   */
  protected $negotiatorManager;

  /**
   * GraphQLConfigOverrides constructor.
   *
   * @param \Drupal\Core\Config\StorageInterface $storage
   *   The config storage service.
   * @param \Drupal\language\LanguageNegotiationMethodManager|null $negotiatorManager
   */
  public function __construct(StorageInterface $storage, LanguageNegotiationMethodManager $negotiatorManager = NULL) {
    $this->baseStorage = $storage;
    $this->negotiatorManager = $negotiatorManager;
  }

  /**
   * {@inheritdoc}
   */
  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 [];
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheSuffix() {
    return 'graphql';
  }

  /**
   * {@inheritdoc}
   */
  public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata($name) {
    return new CacheableMetadata();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GraphQLConfigOverrides::$baseStorage protected property The config storage service.
GraphQLConfigOverrides::$negotiatorManager protected property The negotiator manager service.
GraphQLConfigOverrides::createConfigObject public function Creates a configuration object for use during install and synchronization. Overrides ConfigFactoryOverrideInterface::createConfigObject
GraphQLConfigOverrides::getCacheableMetadata public function Gets the cacheability metadata associated with the config factory override. Overrides ConfigFactoryOverrideInterface::getCacheableMetadata
GraphQLConfigOverrides::getCacheSuffix public function The string to append to the configuration static cache name. Overrides ConfigFactoryOverrideInterface::getCacheSuffix
GraphQLConfigOverrides::loadOverrides public function Returns config overrides. Overrides ConfigFactoryOverrideInterface::loadOverrides
GraphQLConfigOverrides::__construct public function GraphQLConfigOverrides constructor.