From c8ac4e39e1cd61c32c207797fe1f39fefff344aa Mon Sep 17 00:00:00 2001 From: rajeshreeputra Date: Thu, 9 Jan 2025 12:00:33 +0530 Subject: [PATCH 1/2] ACMS-4234: Add config action to import core site studio packages. --- .../Plugin/ConfigAction/BasePackageImport.php | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 modules/acquia_cms_site_studio/src/Plugin/ConfigAction/BasePackageImport.php diff --git a/modules/acquia_cms_site_studio/src/Plugin/ConfigAction/BasePackageImport.php b/modules/acquia_cms_site_studio/src/Plugin/ConfigAction/BasePackageImport.php new file mode 100644 index 000000000..1cf6525f1 --- /dev/null +++ b/modules/acquia_cms_site_studio/src/Plugin/ConfigAction/BasePackageImport.php @@ -0,0 +1,144 @@ +get('config.factory'), + $container->get('settings'), + $container->get('cohesion_sync.package_import_handler'), + $container->get('module_handler'), + ); + } + + /** + * {@inheritdoc} + */ + public function apply(string $configName, mixed $value): void { + if ($configName === 'cohesion.settings' && $value) { + // Update the configuration with the API and organization keys. + $this->updateConfig($configName); + } + } + + /** + * Updates the configuration with API and organization keys. + * + * @param string $configName + * The name of the configuration. + */ + private function updateConfig(string $configName): void { + $config = $this->configFactory->get($configName); + $apiKey = $config->get('api_key'); + $orgKey = $config->get('organization_key'); + + if (!($apiKey && $orgKey)) { + $apiKey = getenv('SITESTUDIO_API_KEY') ?? $this->settings->get('cohesion.settings')->get('api_key'); + $orgKey = getenv('SITESTUDIO_ORG_KEY') ?? $this->settings->get('cohesion.settings')->get('organization_key'); + if (!($apiKey && $orgKey)) { + return; + } + } + + $this->configFactory->getEditable($configName) + ->set('api_key', $apiKey) + ->set('organization_key', $orgKey) + ->save(TRUE); + + // Import the base packages. + $this->importBasePackages(); + } + + /** + * Imports the base Site Studio packages. + */ + private function importBasePackages(): void { + $this->initializeBatch(); + $package_list_path = $this->getPackageListPath(); + $this->importPackages($package_list_path); + $this->processBatchIfCli(); + } + + /** + * Initializes the batch process for importing packages. + */ + private function initializeBatch(): void { + batch_set(AdministrationController::batchAction(TRUE)); + } + + /** + * Gets the path to the package list file. + * + * @return string + * The path to the package list file. + */ + private function getPackageListPath(): string { + $module_path = $this->moduleHandler->getModule('acquia_cms_site_studio')->getPath(); + return $module_path . '/config/site_studio/site_studio.packages.yml'; + } + + /** + * Imports packages from the specified path. + * + * @param string $package_list_path + * The path to the package list file. + */ + private function importPackages(string $package_list_path): void { + $this->packageImportHandler->importPackagesFromPath($package_list_path); + } + + /** + * Processes the batch if running in CLI mode. + */ + private function processBatchIfCli(): void { + if (PHP_SAPI === 'cli') { + drush_backend_batch_process(); + } + } + +} From 38eef86b645bfbd6dc25236ae6cbac207b70b816 Mon Sep 17 00:00:00 2001 From: rajeshreeputra Date: Thu, 9 Jan 2025 10:49:36 +0530 Subject: [PATCH 2/2] ACMS-4237: Add patch for site studio drupal 11.1 compatibility. --- composer.json | 3 +++ composer.lock | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index dd70c2e6d..03245b0cd 100644 --- a/composer.json +++ b/composer.json @@ -322,6 +322,9 @@ "drupal/core": "-p2" }, "patches": { + "acquia/cohesion": { + "3340269 - Site Studio Drupal 11.1 compatibility": "https://www.drupal.org/files/issues/2025-01-09/3340269-site-studio-drupal-11-1-compatibility.patch" + }, "drupal/core": { "3328187 - PHP Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in docroot/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php on line 112": "https://git.drupalcode.org/project/drupal/-/merge_requests/3142.patch", "Fix failing test for site studio due to missing file": "https://gist.githubusercontent.com/chandan-singh7929/978c8c3c8b6f1e2de23492e7e562c0c3/raw/f0e7770d94be862e5495ca25662a0a0d5672b785/bypass-library-version-core.patch" diff --git a/composer.lock b/composer.lock index 4a55c2782..674993546 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f7f9e623cf8da30e566ee0d0052fb980", + "content-hash": "a285aa0789cbf1a0b52f8b799237b02c", "packages": [ { "name": "acquia/acquia-cms-starterkit", @@ -83,16 +83,16 @@ }, { "name": "acquia/cohesion", - "version": "8.0.1", + "version": "8.0.2", "source": { "type": "git", "url": "https://github.com/acquia/cohesion.git", - "reference": "9c1fe03d979508e4d606ed3033143f9b345bcce3" + "reference": "edea0bfa3ebc42c519b30d831aaf6fb19107030f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/acquia/cohesion/zipball/9c1fe03d979508e4d606ed3033143f9b345bcce3", - "reference": "9c1fe03d979508e4d606ed3033143f9b345bcce3", + "url": "https://api.github.com/repos/acquia/cohesion/zipball/edea0bfa3ebc42c519b30d831aaf6fb19107030f", + "reference": "edea0bfa3ebc42c519b30d831aaf6fb19107030f", "shasum": "" }, "require": { @@ -140,9 +140,9 @@ ], "description": "Site Studio", "support": { - "source": "https://github.com/acquia/cohesion/tree/8.0.1" + "source": "https://github.com/acquia/cohesion/tree/8.0.2" }, - "time": "2024-10-08T11:09:42+00:00" + "time": "2024-11-20T19:17:26+00:00" }, { "name": "acquia/cohesion-theme",