graphql_compose-1.0.0-beta20/graphql_compose.install

graphql_compose.install
<?php

/**
 * @file
 * GraphQL Compose module file.
 */

declare(strict_types=1);

use Drupal\graphql_compose\Utility\ComposeProviders;

/**
 * Change config to match 3.0.x.
 */
function graphql_compose_update_30000(&$sandbox) {
  $configFactory = \Drupal::configFactory();

  /** @var \Drupal\graphql\Entity\ServerInterface[] $servers */
  $servers = \Drupal::entityTypeManager()
    ->getStorage('graphql_server')
    ->loadByProperties([
      'schema' => 'graphql_compose',
    ]);

  $config = $configFactory->getEditable('graphql_compose.settings');
  $hasConfig = !empty($config->getRawData());

  foreach ($servers as $server) {
    if ($hasConfig) {
      $clone = clone $config;
      $clone->setName('graphql_compose.settings.' . $server->id());
      $clone->save();
    }

    $server->set('schema_configuration', [
      'graphql_compose' => [
        'providers' => ComposeProviders::all(),
      ],
    ])->save();
  }

  $config->delete();

  _graphql_compose_cache_flush();
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc