From 9c2df342f30457878e5f2ec990462eeedf2310de Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Mon, 25 Nov 2024 21:59:26 +0530 Subject: [PATCH 1/4] Drupal 11 compatible changes --- apigee_edge.info.yml | 4 ++-- modules/apigee_edge_actions/apigee_edge_actions.info.yml | 2 +- .../apigee_edge_actions_debug.info.yml | 2 +- .../apigee_edge_actions_examples.info.yml | 2 +- .../apigee_edge_apiproduct_rbac.info.yml | 4 ++-- .../apigee_edge_apiproduct_rbac.libraries.yml | 2 +- .../apigee_edge_apiproduct_rbac.module | 2 +- modules/apigee_edge_debug/apigee_edge_debug.info.yml | 4 ++-- modules/apigee_edge_teams/apigee_edge_teams.info.yml | 4 ++-- .../config/optional/views.view.team_invitations.yml | 2 -- tests/modules/apigee_edge_test/apigee_edge_test.info.yml | 2 +- .../apigee_edge_test_app_keys.info.yml | 2 +- .../apigee_mock_api_client/apigee_mock_api_client.info.yml | 4 ++-- 13 files changed, 17 insertions(+), 19 deletions(-) diff --git a/apigee_edge.info.yml b/apigee_edge.info.yml index 66e8fe600..cbcd83a1d 100644 --- a/apigee_edge.info.yml +++ b/apigee_edge.info.yml @@ -3,7 +3,7 @@ description: Apigee Drupal integration. package: Apigee type: module -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 dependencies: - drupal:file @@ -16,4 +16,4 @@ dependencies: configure: apigee_edge.settings -php: 8.1 +php: 8.3 diff --git a/modules/apigee_edge_actions/apigee_edge_actions.info.yml b/modules/apigee_edge_actions/apigee_edge_actions.info.yml index b106cd621..29f6ab108 100644 --- a/modules/apigee_edge_actions/apigee_edge_actions.info.yml +++ b/modules/apigee_edge_actions/apigee_edge_actions.info.yml @@ -2,7 +2,7 @@ name: Apigee Edge Actions description: Rules integration for Apigee Edge. package: Apigee (Experimental) type: module -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 configure: entity.rules_reaction_rule.collection dependencies: - apigee_edge:apigee_edge diff --git a/modules/apigee_edge_actions/modules/apigee_edge_actions_debug/apigee_edge_actions_debug.info.yml b/modules/apigee_edge_actions/modules/apigee_edge_actions_debug/apigee_edge_actions_debug.info.yml index 82c2bfe2d..35ace1e1d 100644 --- a/modules/apigee_edge_actions/modules/apigee_edge_actions_debug/apigee_edge_actions_debug.info.yml +++ b/modules/apigee_edge_actions/modules/apigee_edge_actions_debug/apigee_edge_actions_debug.info.yml @@ -2,6 +2,6 @@ name: Apigee Edge Actions Debug description: Logs debug information for Apigee Edge Actions. package: Apigee (Experimental) type: module -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 dependencies: - apigee_edge_actions:apigee_edge_actions diff --git a/modules/apigee_edge_actions/modules/apigee_edge_actions_examples/apigee_edge_actions_examples.info.yml b/modules/apigee_edge_actions/modules/apigee_edge_actions_examples/apigee_edge_actions_examples.info.yml index 48a45a634..ec89980b4 100644 --- a/modules/apigee_edge_actions/modules/apigee_edge_actions_examples/apigee_edge_actions_examples.info.yml +++ b/modules/apigee_edge_actions/modules/apigee_edge_actions_examples/apigee_edge_actions_examples.info.yml @@ -2,7 +2,7 @@ name: Apigee Edge Actions Examples description: Example rules for Apigee Edge. package: Apigee (Experimental) type: module -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 configure: entity.rules_reaction_rule.collection dependencies: - apigee_edge_actions:apigee_edge_actions diff --git a/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.info.yml b/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.info.yml index 8539f2bad..86595a79f 100644 --- a/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.info.yml +++ b/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.info.yml @@ -3,11 +3,11 @@ description: Role based access control over view operation on API products. package: Apigee type: module -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 dependencies: - apigee_edge:apigee_edge configure: apigee_edge.settings.developer.api_product_access -php: "8.1" +php: "8.3" diff --git a/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.libraries.yml b/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.libraries.yml index 3659ac1b4..58e4026d5 100644 --- a/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.libraries.yml +++ b/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.libraries.yml @@ -1,4 +1,4 @@ -admin: +apigee_edge_apiproduct_rbac.admin: version: 1.1 css: theme: diff --git a/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.module b/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.module index 7896c0e51..00fa7c7b2 100644 --- a/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.module +++ b/modules/apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.module @@ -233,7 +233,7 @@ function apigee_edge_apiproduct_rbac_form_apigee_edge_api_product_access_control '#value' => $product_names, ]; - $form['#attached']['library'][] = 'apigee_edge_apiproduct_rbac/admin'; + $form['#attached']['library'][] = 'apigee_edge_apiproduct_rbac/apigee_edge_apiproduct_rbac.admin'; $form['#submit'][] = 'apigee_edge_apiproduct_rbac_form_apigee_edge_api_product_access_control_form_submit'; } diff --git a/modules/apigee_edge_debug/apigee_edge_debug.info.yml b/modules/apigee_edge_debug/apigee_edge_debug.info.yml index bf8ce1257..78fb3431e 100644 --- a/modules/apigee_edge_debug/apigee_edge_debug.info.yml +++ b/modules/apigee_edge_debug/apigee_edge_debug.info.yml @@ -3,11 +3,11 @@ description: Debug helper for Apigee Edge Drupal integration. package: Apigee type: module -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 dependencies: - apigee_edge:apigee_edge configure: apigee_edge_debug.settings -php: "8.1" +php: "8.3" diff --git a/modules/apigee_edge_teams/apigee_edge_teams.info.yml b/modules/apigee_edge_teams/apigee_edge_teams.info.yml index 4898cb7c3..148439330 100644 --- a/modules/apigee_edge_teams/apigee_edge_teams.info.yml +++ b/modules/apigee_edge_teams/apigee_edge_teams.info.yml @@ -3,7 +3,7 @@ description: Provides shared app functionality by allowing developers to be orga package: Apigee type: module -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 dependencies: - apigee_edge:apigee_edge @@ -12,4 +12,4 @@ dependencies: configure: apigee_edge_teams.settings.team -php: "8.1" +php: "8.3" diff --git a/modules/apigee_edge_teams/config/optional/views.view.team_invitations.yml b/modules/apigee_edge_teams/config/optional/views.view.team_invitations.yml index 461ae109c..1deed7715 100644 --- a/modules/apigee_edge_teams/config/optional/views.view.team_invitations.yml +++ b/modules/apigee_edge_teams/config/optional/views.view.team_invitations.yml @@ -662,7 +662,6 @@ display: default_argument_type: fixed default_argument_options: argument: '' - default_argument_skip_url: false summary_options: base_path: '' count: true @@ -767,7 +766,6 @@ display: default_argument_type: user default_argument_options: user: false - default_argument_skip_url: false summary_options: base_path: '' count: true diff --git a/tests/modules/apigee_edge_test/apigee_edge_test.info.yml b/tests/modules/apigee_edge_test/apigee_edge_test.info.yml index 44180c3ef..19ed4e620 100644 --- a/tests/modules/apigee_edge_test/apigee_edge_test.info.yml +++ b/tests/modules/apigee_edge_test/apigee_edge_test.info.yml @@ -1,7 +1,7 @@ name: 'Apigee Edge Testing' type: module description: 'Support module for the Apigee Edge tests.' -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 package: Testing dependencies: diff --git a/tests/modules/apigee_edge_test_app_keys/apigee_edge_test_app_keys.info.yml b/tests/modules/apigee_edge_test_app_keys/apigee_edge_test_app_keys.info.yml index 38c0dd6b3..f78962b35 100644 --- a/tests/modules/apigee_edge_test_app_keys/apigee_edge_test_app_keys.info.yml +++ b/tests/modules/apigee_edge_test_app_keys/apigee_edge_test_app_keys.info.yml @@ -1,7 +1,7 @@ name: 'Apigee Edge Testing: App keys' type: module description: 'Support module for the Apigee Edge tests: Mocks app key generation via a 3rd party service.' -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 package: Testing dependencies: diff --git a/tests/modules/apigee_mock_api_client/apigee_mock_api_client.info.yml b/tests/modules/apigee_mock_api_client/apigee_mock_api_client.info.yml index 7543f60b5..2c1e0e2e8 100644 --- a/tests/modules/apigee_mock_api_client/apigee_mock_api_client.info.yml +++ b/tests/modules/apigee_mock_api_client/apigee_mock_api_client.info.yml @@ -3,9 +3,9 @@ description: Helpers and an API middleware used for testing. package: Apigee type: module -core_version_requirement: ^10 +core_version_requirement: ^10.3 || ^11 dependencies: - apigee_edge:apigee_edge -php: "8.0" +php: "8.3" From 2b4c551ebc44500115b77c3d4d67503c51b846da Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Mon, 25 Nov 2024 22:48:30 +0530 Subject: [PATCH 2/4] Deprecated code updated --- modules/apigee_edge_teams/src/TeamPermissionHandler.php | 2 +- src/Element/ApigeeEntityListElement.php | 6 +++--- src/Element/ApigeeSecret.php | 6 +++--- src/Element/AppCredentialElement.php | 6 +++--- src/Element/AppCredentialProductListElement.php | 6 +++--- src/Element/StatusPropertyElement.php | 6 +++--- src/Entity/ListBuilder/AppListBuilder.php | 2 +- src/OauthTokenFileStorage.php | 3 ++- src/Plugin/KeyProvider/PrivateFileKeyProvider.php | 3 ++- tests/src/Kernel/OauthTokenFileStorageTest.php | 3 ++- 10 files changed, 23 insertions(+), 20 deletions(-) diff --git a/modules/apigee_edge_teams/src/TeamPermissionHandler.php b/modules/apigee_edge_teams/src/TeamPermissionHandler.php index 75d36ca36..d7dc3734d 100644 --- a/modules/apigee_edge_teams/src/TeamPermissionHandler.php +++ b/modules/apigee_edge_teams/src/TeamPermissionHandler.php @@ -299,7 +299,7 @@ protected function sortPermissions(array $all_permissions = []) { protected function getModuleNames(): array { $modules = []; foreach (array_keys($this->moduleHandler->getModuleList()) as $module) { - $modules[$module] = $this->moduleHandler->getName($module); + $modules[$module] = \Drupal::service('extension.list.module')->getName($module); } asort($modules); return $modules; diff --git a/src/Element/ApigeeEntityListElement.php b/src/Element/ApigeeEntityListElement.php index 14c476b5d..071d2465f 100644 --- a/src/Element/ApigeeEntityListElement.php +++ b/src/Element/ApigeeEntityListElement.php @@ -22,15 +22,15 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\Core\Render\Element\RenderElement; +use Drupal\Core\Render\Element\RenderElementBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides an element for listing Apigee entities. * - * @RenderElement("apigee_entity_list") + * @RenderElementBase("apigee_entity_list") */ -class ApigeeEntityListElement extends RenderElement implements ContainerFactoryPluginInterface { +class ApigeeEntityListElement extends RenderElementBase implements ContainerFactoryPluginInterface { /** * The entity type manager. diff --git a/src/Element/ApigeeSecret.php b/src/Element/ApigeeSecret.php index 056609b53..5249b874c 100644 --- a/src/Element/ApigeeSecret.php +++ b/src/Element/ApigeeSecret.php @@ -20,14 +20,14 @@ namespace Drupal\apigee_edge\Element; -use Drupal\Core\Render\Element\RenderElement; +use Drupal\Core\Render\Element\RenderElementBase; /** * Provides a secret element. * - * @RenderElement("apigee_secret") + * @RenderElementBase("apigee_secret") */ -class ApigeeSecret extends RenderElement { +class ApigeeSecret extends RenderElementBase { /** * {@inheritdoc} diff --git a/src/Element/AppCredentialElement.php b/src/Element/AppCredentialElement.php index 8cbd77672..4363e5ec2 100644 --- a/src/Element/AppCredentialElement.php +++ b/src/Element/AppCredentialElement.php @@ -20,14 +20,14 @@ namespace Drupal\apigee_edge\Element; -use Drupal\Core\Render\Element\RenderElement; +use Drupal\Core\Render\Element\RenderElementBase; /** * Provides an app credential element. * - * @RenderElement("app_credential") + * @RenderElementBase("app_credential") */ -class AppCredentialElement extends RenderElement { +class AppCredentialElement extends RenderElementBase { /** * {@inheritdoc} diff --git a/src/Element/AppCredentialProductListElement.php b/src/Element/AppCredentialProductListElement.php index e7badae0d..074e75382 100644 --- a/src/Element/AppCredentialProductListElement.php +++ b/src/Element/AppCredentialProductListElement.php @@ -20,14 +20,14 @@ namespace Drupal\apigee_edge\Element; -use Drupal\Core\Render\Element\RenderElement; +use Drupal\Core\Render\Element\RenderElementBase; /** * Provides a product listing element for app credentials. * - * @RenderElement("app_credential_product_list") + * @RenderElementBase("app_credential_product_list") */ -class AppCredentialProductListElement extends RenderElement { +class AppCredentialProductListElement extends RenderElementBase { /** * {@inheritdoc} diff --git a/src/Element/StatusPropertyElement.php b/src/Element/StatusPropertyElement.php index 2224d8e45..9acce1dd7 100644 --- a/src/Element/StatusPropertyElement.php +++ b/src/Element/StatusPropertyElement.php @@ -19,14 +19,14 @@ namespace Drupal\apigee_edge\Element; -use Drupal\Core\Render\Element\RenderElement; +use Drupal\Core\Render\Element\RenderElementBase; /** * Provides a status property element. * - * @RenderElement("status_property") + * @RenderElementBase("status_property") */ -class StatusPropertyElement extends RenderElement { +class StatusPropertyElement extends RenderElementBase { /** * Indicator status configuration id: OK. diff --git a/src/Entity/ListBuilder/AppListBuilder.php b/src/Entity/ListBuilder/AppListBuilder.php index 85e3c1784..72eb15c44 100644 --- a/src/Entity/ListBuilder/AppListBuilder.php +++ b/src/Entity/ListBuilder/AppListBuilder.php @@ -290,7 +290,7 @@ protected function buildWarningRow(AppInterface $app, array &$rows) { $url = Url::fromUserInput($this->requestStack->getCurrentRequest()->getRequestUri(), $link_options); $link = Link::fromTextAndUrl($this->t('Show details'), $url); $build['warning-toggle'] = $link->toRenderable(); - $rows[$info_row_css_id]['data']['status']['data'] = $this->renderer->renderPlain($build); + $rows[$info_row_css_id]['data']['status']['data'] = $this->renderer->renderInIsolation($build); $row['data']['info'] = [ 'colspan' => count($this->buildHeader()), ]; diff --git a/src/OauthTokenFileStorage.php b/src/OauthTokenFileStorage.php index 2f8c33cf1..7b969ce35 100644 --- a/src/OauthTokenFileStorage.php +++ b/src/OauthTokenFileStorage.php @@ -22,6 +22,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\File\Exception\FileException; +Use Drupal\Core\File\FileExists; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Logger\LoggerChannelInterface; use Drupal\apigee_edge\Exception\OauthTokenStorageException; @@ -172,7 +173,7 @@ public function saveToken(array $data): void { try { $this->checkRequirements(); // Write the obfuscated token data to a private file. - $this->fileSystem->saveData(base64_encode(Json::encode($data)), $this->tokenFilePath, FileSystemInterface::EXISTS_REPLACE); + $this->fileSystem->saveData(base64_encode(Json::encode($data)), $this->tokenFilePath, FileExists::Replace); } catch (FileException $e) { $this->logger->critical('Error saving OAuth token file.'); diff --git a/src/Plugin/KeyProvider/PrivateFileKeyProvider.php b/src/Plugin/KeyProvider/PrivateFileKeyProvider.php index f8fdd619b..667003db5 100644 --- a/src/Plugin/KeyProvider/PrivateFileKeyProvider.php +++ b/src/Plugin/KeyProvider/PrivateFileKeyProvider.php @@ -20,6 +20,7 @@ namespace Drupal\apigee_edge\Plugin\KeyProvider; use Drupal\Core\File\Exception\FileException; +Use Drupal\Core\File\FileExists; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Utility\Error; @@ -143,7 +144,7 @@ public function setKeyValue(KeyInterface $key, $key_value) { try { // Save the token data. return $this->getFileSystem() - ->saveData($key_value, $file_uri, FileSystemInterface::EXISTS_REPLACE); + ->saveData($key_value, $file_uri, FileExists::Replace); } catch (FileException $e) { return FALSE; diff --git a/tests/src/Kernel/OauthTokenFileStorageTest.php b/tests/src/Kernel/OauthTokenFileStorageTest.php index ccdeb80bc..56645408c 100644 --- a/tests/src/Kernel/OauthTokenFileStorageTest.php +++ b/tests/src/Kernel/OauthTokenFileStorageTest.php @@ -21,6 +21,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\DependencyInjection\ContainerBuilder; +Use Drupal\Core\File\FileExists; use Drupal\Core\File\FileSystemInterface; use Drupal\KernelTests\KernelTestBase; use Drupal\apigee_edge\Exception\OauthTokenStorageException; @@ -183,7 +184,7 @@ public function testStaticCaching() { $stored_token['access_token'] = mb_strtolower($this->randomMachineName(32)); \Drupal::service('file_system')->saveData( base64_encode(Json::encode($stored_token)), - $this->tokenFileUri(), FileSystemInterface::EXISTS_REPLACE); + $this->tokenFileUri(), FileExists::Replace); // Make sure the cached version is still returned. $this->assertSame($access_token, $storage->getAccessToken()); From 5965c9de542fc6279767160e1fad704a35c407b8 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Wed, 27 Nov 2024 20:32:24 +0530 Subject: [PATCH 3/4] Changes for use statement --- src/OauthTokenFileStorage.php | 2 +- src/Plugin/KeyProvider/PrivateFileKeyProvider.php | 2 +- tests/src/Kernel/OauthTokenFileStorageTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OauthTokenFileStorage.php b/src/OauthTokenFileStorage.php index 7b969ce35..9073c09f6 100644 --- a/src/OauthTokenFileStorage.php +++ b/src/OauthTokenFileStorage.php @@ -22,7 +22,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\File\Exception\FileException; -Use Drupal\Core\File\FileExists; +use Drupal\Core\File\FileExists; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Logger\LoggerChannelInterface; use Drupal\apigee_edge\Exception\OauthTokenStorageException; diff --git a/src/Plugin/KeyProvider/PrivateFileKeyProvider.php b/src/Plugin/KeyProvider/PrivateFileKeyProvider.php index 667003db5..277cd5093 100644 --- a/src/Plugin/KeyProvider/PrivateFileKeyProvider.php +++ b/src/Plugin/KeyProvider/PrivateFileKeyProvider.php @@ -20,7 +20,7 @@ namespace Drupal\apigee_edge\Plugin\KeyProvider; use Drupal\Core\File\Exception\FileException; -Use Drupal\Core\File\FileExists; +use Drupal\Core\File\FileExists; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Utility\Error; diff --git a/tests/src/Kernel/OauthTokenFileStorageTest.php b/tests/src/Kernel/OauthTokenFileStorageTest.php index 56645408c..e179624e8 100644 --- a/tests/src/Kernel/OauthTokenFileStorageTest.php +++ b/tests/src/Kernel/OauthTokenFileStorageTest.php @@ -21,7 +21,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\DependencyInjection\ContainerBuilder; -Use Drupal\Core\File\FileExists; +use Drupal\Core\File\FileExists; use Drupal\Core\File\FileSystemInterface; use Drupal\KernelTests\KernelTestBase; use Drupal\apigee_edge\Exception\OauthTokenStorageException; From a2ec295c522bd75abca84ff794ddb7dc78fcbe5d Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Fri, 6 Dec 2024 21:38:57 +0530 Subject: [PATCH 4/4] Changes to solve issues on module install --- src/Entity/FieldableEdgeEntityBase.php | 2 +- src/MemoryCacheFactory.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Entity/FieldableEdgeEntityBase.php b/src/Entity/FieldableEdgeEntityBase.php index 129d0f0ef..8f36d1428 100644 --- a/src/Entity/FieldableEdgeEntityBase.php +++ b/src/Entity/FieldableEdgeEntityBase.php @@ -78,7 +78,7 @@ abstract class FieldableEdgeEntityBase extends EdgeEntityBase implements Fieldab /** * {@inheritdoc} */ - public function __sleep() { + public function __sleep(): array { $this->fields = []; $this->fieldDefinitions = NULL; return parent::__sleep(); diff --git a/src/MemoryCacheFactory.php b/src/MemoryCacheFactory.php index bd20b857a..ccfd9c8bd 100644 --- a/src/MemoryCacheFactory.php +++ b/src/MemoryCacheFactory.php @@ -20,6 +20,7 @@ namespace Drupal\apigee_edge; +use Drupal\Component\Datetime\Time; use Drupal\Core\Cache\MemoryCache\MemoryCache; use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; @@ -65,7 +66,7 @@ public function __construct(?string $prefix = NULL) { public function get($bin): MemoryCacheInterface { $bin = "{$this->prefix}_{$bin}"; if (!isset($this->bins[$bin])) { - $this->bins[$bin] = new MemoryCache(); + $this->bins[$bin] = new MemoryCache(new Time()); } return $this->bins[$bin]; }