View source
<?php
function graphql_requirements($phase) {
$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,
],
];
}
function graphql_uninstall() {
$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();
}