You are here

graphql.install in GraphQL 8.3

Same filename and directory in other branches
  1. 8.4 graphql.install

File

graphql.install
View source
<?php

/**
 * Implements hook_requirements().
 */
function graphql_requirements($phase) {

  // This is the first reference into the library performed by the module.
  $libraryAvailable = class_exists('\\GraphQL\\GraphQL');
  $libraryArg = [
    '@library' => 'webonyx/graphql-php',
  ];
  return [
    'graphql' => [
      'title' => 'GraphQL',
      'description' => !empty($libraryAvailable) ? t('@library component available', $libraryArg) : t('@library component not found', $libraryArg),
      'severity' => !empty($libraryAvailable) ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    ],
  ];
}

/**
 * Implements hook_uninstall().
 */
function graphql_uninstall() {

  // Remove the config keys set in GraphQLConfigOverrides::loadOverrides().

  /** @var \Drupal\Core\Config\ConfigFactoryInterface $configFactory */
  $configFactory = \Drupal::getContainer()
    ->get('config.factory');
  $languageTypes = $configFactory
    ->getEditable('language.types');
  $negotiation = $languageTypes
    ->get('negotiation');
  foreach (array_keys($negotiation) as $type) {
    unset($negotiation[$type]['enabled']['language-graphql']);
  }
  $languageTypes
    ->set('negotiation', $negotiation)
    ->save();
}

Functions