From f5b2062434b5d5fd387dbf6de32853f97021e97c Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 31 Oct 2024 08:28:45 +0100 Subject: [PATCH] 3484814: Drupal 11 compatibility for version 3.4 by @albertosilva --- graphql.info.yml | 2 +- modules/graphql_core/graphql_core.info.yml | 2 +- .../graphql_block_test.info.yml | 2 +- .../graphql_breadcrumbs_test.info.yml | 2 +- .../graphql_context_test.info.yml | 2 +- .../graphql_requests_test.info.yml | 2 +- .../graphql_test_menu.info.yml | 2 +- src/Controller/SchemaOverviewController.php | 18 +++++++++++++++--- .../GraphQL/Traits/DescribablePluginTrait.php | 4 ++-- .../graphql_enum_test.info.yml | 2 +- .../graphql_override_test.info.yml | 2 +- .../graphql_plugin_test.info.yml | 2 +- .../modules/graphql_test/graphql_test.info.yml | 2 +- 13 files changed, 28 insertions(+), 16 deletions(-) diff --git a/graphql.info.yml b/graphql.info.yml index ebcdc7b73..866884c66 100644 --- a/graphql.info.yml +++ b/graphql.info.yml @@ -3,4 +3,4 @@ type: module description: "Base module for integrating GraphQL with Drupal." package: GraphQL configure: graphql.config_page -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 diff --git a/modules/graphql_core/graphql_core.info.yml b/modules/graphql_core/graphql_core.info.yml index 68fbf8208..e46747bb7 100644 --- a/modules/graphql_core/graphql_core.info.yml +++ b/modules/graphql_core/graphql_core.info.yml @@ -2,7 +2,7 @@ name: GraphQL Core type: module description: "Provides type system plugins and derivers on behalf of core modules." package: GraphQL -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 dependencies: - graphql:graphql - drupal:path_alias diff --git a/modules/graphql_core/tests/modules/graphql_block_test/graphql_block_test.info.yml b/modules/graphql_core/tests/modules/graphql_block_test/graphql_block_test.info.yml index e26adeb25..f11f3ef4f 100644 --- a/modules/graphql_core/tests/modules/graphql_block_test/graphql_block_test.info.yml +++ b/modules/graphql_core/tests/modules/graphql_block_test/graphql_block_test.info.yml @@ -1,7 +1,7 @@ name: "GraphQL Test: Blocks" type: module package: Testing -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 hidden: TRUE dependencies: - drupal:block diff --git a/modules/graphql_core/tests/modules/graphql_breadcrumbs_test/graphql_breadcrumbs_test.info.yml b/modules/graphql_core/tests/modules/graphql_breadcrumbs_test/graphql_breadcrumbs_test.info.yml index 59d3b5d23..9c0310398 100644 --- a/modules/graphql_core/tests/modules/graphql_breadcrumbs_test/graphql_breadcrumbs_test.info.yml +++ b/modules/graphql_core/tests/modules/graphql_breadcrumbs_test/graphql_breadcrumbs_test.info.yml @@ -2,7 +2,7 @@ name: GraphQL Breadcrumbs test type: module description: "Test for breadcrumbs." package: Testing -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 hidden: TRUE dependencies: - graphql:graphql_core diff --git a/modules/graphql_core/tests/modules/graphql_context_test/graphql_context_test.info.yml b/modules/graphql_core/tests/modules/graphql_context_test/graphql_context_test.info.yml index 9f4c58752..042b22108 100644 --- a/modules/graphql_core/tests/modules/graphql_context_test/graphql_context_test.info.yml +++ b/modules/graphql_core/tests/modules/graphql_context_test/graphql_context_test.info.yml @@ -2,7 +2,7 @@ type: module name: GraphQL Context Test description: Test contexts in graphql schema. package: Testing -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 hidden: TRUE dependencies: - graphql:graphql_core diff --git a/modules/graphql_core/tests/modules/graphql_requests_test/graphql_requests_test.info.yml b/modules/graphql_core/tests/modules/graphql_requests_test/graphql_requests_test.info.yml index ffe5372bc..0fe520b10 100644 --- a/modules/graphql_core/tests/modules/graphql_requests_test/graphql_requests_test.info.yml +++ b/modules/graphql_core/tests/modules/graphql_requests_test/graphql_requests_test.info.yml @@ -2,7 +2,7 @@ type: module name: GraphQL Requests Test description: Dummy callbacks for internal request testing. package: Testing -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 hidden: TRUE dependencies: - graphql:graphql_core diff --git a/modules/graphql_core/tests/modules/graphql_test_menu/graphql_test_menu.info.yml b/modules/graphql_core/tests/modules/graphql_test_menu/graphql_test_menu.info.yml index 8a8eb9ebe..2f7329286 100644 --- a/modules/graphql_core/tests/modules/graphql_test_menu/graphql_test_menu.info.yml +++ b/modules/graphql_core/tests/modules/graphql_test_menu/graphql_test_menu.info.yml @@ -1,7 +1,7 @@ name: "GraphQL Tests: Menu" type: module package: Testing -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 hidden: TRUE dependencies: - drupal:system diff --git a/src/Controller/SchemaOverviewController.php b/src/Controller/SchemaOverviewController.php index 86ee064bf..2ded5e931 100644 --- a/src/Controller/SchemaOverviewController.php +++ b/src/Controller/SchemaOverviewController.php @@ -3,6 +3,7 @@ namespace Drupal\graphql\Controller; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\Extension\ModuleExtensionList; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\graphql\Plugin\SchemaPluginManager; @@ -26,12 +27,20 @@ class SchemaOverviewController implements ContainerInjectionInterface { */ protected $moduleHandler; + /** + * The module extension list service. + * + * @var \Drupal\Core\Extension\ModuleExtensionList + */ + protected $moduleExtensionList; + /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('module_handler'), + $container->get('extension.list.module'), $container->get('plugin.manager.graphql.schema') ); } @@ -40,12 +49,15 @@ public static function create(ContainerInterface $container) { * SchemaOverviewController constructor. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler - * The module handler srevice. + * The module handler service. + * @param \Drupal\Core\Extension\ModuleExtensionList $moduleExtensionList + * The module extension list service * @param \Drupal\graphql\Plugin\SchemaPluginManager $schemaManager * The schema plugin manager service. */ - public function __construct(ModuleHandlerInterface $moduleHandler, SchemaPluginManager $schemaManager) { + public function __construct(ModuleHandlerInterface $moduleHandler, ModuleExtensionList $moduleExtensionList, SchemaPluginManager $schemaManager) { $this->schemaManager = $schemaManager; + $this->moduleExtensionList = $moduleExtensionList; $this->moduleHandler = $moduleHandler; } @@ -74,7 +86,7 @@ public function listSchemas() { ]; $table["schema:$key"]['provider'] = [ - '#plain_text' => $this->moduleHandler->getName($definition['provider']), + '#plain_text' => $this->moduleExtensionList->getName($definition['provider']), ]; $table["schema:$key"]['operations'] = $this->buildOperations($key, $definition); diff --git a/src/Plugin/GraphQL/Traits/DescribablePluginTrait.php b/src/Plugin/GraphQL/Traits/DescribablePluginTrait.php index b64c91b37..946631688 100644 --- a/src/Plugin/GraphQL/Traits/DescribablePluginTrait.php +++ b/src/Plugin/GraphQL/Traits/DescribablePluginTrait.php @@ -10,8 +10,8 @@ trait DescribablePluginTrait { * @return null|string */ protected function buildDescription($definition) { - if (!empty($definition['description'])) { - return (string) $definition['description']; + if (!empty($definition['description']) && !is_null($definition['description'])) { + return (string) ($definition['description']); } return NULL; diff --git a/tests/modules/graphql_enum_test/graphql_enum_test.info.yml b/tests/modules/graphql_enum_test/graphql_enum_test.info.yml index 04f5e58e4..4a5b3049e 100644 --- a/tests/modules/graphql_enum_test/graphql_enum_test.info.yml +++ b/tests/modules/graphql_enum_test/graphql_enum_test.info.yml @@ -2,7 +2,7 @@ type: module name: GraphQL Enumeration Test description: Test enumeration plugins. package: Testing -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 hidden: TRUE dependencies: - graphql:graphql diff --git a/tests/modules/graphql_override_test/graphql_override_test.info.yml b/tests/modules/graphql_override_test/graphql_override_test.info.yml index e3a836359..06fb4b626 100644 --- a/tests/modules/graphql_override_test/graphql_override_test.info.yml +++ b/tests/modules/graphql_override_test/graphql_override_test.info.yml @@ -2,7 +2,7 @@ type: module name: GraphQL Override Test description: Test plugin overrides in graphql schema. package: Testing -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 hidden: TRUE dependencies: - graphql:graphql_plugin_test diff --git a/tests/modules/graphql_plugin_test/graphql_plugin_test.info.yml b/tests/modules/graphql_plugin_test/graphql_plugin_test.info.yml index 979ee022d..021f71b24 100644 --- a/tests/modules/graphql_plugin_test/graphql_plugin_test.info.yml +++ b/tests/modules/graphql_plugin_test/graphql_plugin_test.info.yml @@ -2,7 +2,7 @@ type: module name: GraphQL Plugin Test description: Test plugin based graphql schema. package: Testing -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 hidden: TRUE dependencies: - graphql:graphql diff --git a/tests/modules/graphql_test/graphql_test.info.yml b/tests/modules/graphql_test/graphql_test.info.yml index 9f0278f3c..9238d99b0 100644 --- a/tests/modules/graphql_test/graphql_test.info.yml +++ b/tests/modules/graphql_test/graphql_test.info.yml @@ -2,7 +2,7 @@ type: module name: GraphQL Test description: Provides a default schema plugin for testing. package: Testing -core_version_requirement: ^9 || ^10 +core_version_requirement: ^9 || ^10 || ^11 hidden: TRUE dependencies: - graphql:graphql