From d92b77d8185bf65423d4face6f78e92a3ecfc7a1 Mon Sep 17 00:00:00 2001 From: Ankit Pathak Date: Tue, 23 Jan 2024 14:52:19 +0530 Subject: [PATCH] ACMS-1890: PR feedback for drs config override. --- composer.json | 2 +- composer.lock | 15 ++-- settings/config.settings.php | 73 ------------------- src/Robo/Commands/Blt/MigrateToDrsCommand.php | 21 +++--- 4 files changed, 20 insertions(+), 91 deletions(-) delete mode 100644 settings/config.settings.php diff --git a/composer.json b/composer.json index 728357a3e..a5db88030 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "composer-plugin-api": "^2.0", "composer-runtime-api": "^2.0", "acquia/drupal-environment-detector": "^1.5.3", - "acquia/drupal-recommended-settings": "dev-develop", + "acquia/drupal-recommended-settings": "dev-ACMS-3508", "consolidation/comments": "^1.0", "consolidation/config": "^2.0.0", "consolidation/robo": "^4", diff --git a/composer.lock b/composer.lock index f2aef8c0a..a1da7f838 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": "8798857a1adbb0eb26c6930401091b6e", + "content-hash": "9419d1bcd0af1123bfe04300d956a99e", "packages": [ { "name": "acquia/drupal-environment-detector", @@ -61,16 +61,16 @@ }, { "name": "acquia/drupal-recommended-settings", - "version": "dev-develop", + "version": "dev-ACMS-3508", "source": { "type": "git", "url": "https://github.com/acquia/drupal-recommended-settings.git", - "reference": "3bdd6881a214a67db84ada2b6ca1966130176e42" + "reference": "0db00f6f260a3d56c554787ef0944e26d79251da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/acquia/drupal-recommended-settings/zipball/3bdd6881a214a67db84ada2b6ca1966130176e42", - "reference": "3bdd6881a214a67db84ada2b6ca1966130176e42", + "url": "https://api.github.com/repos/acquia/drupal-recommended-settings/zipball/0db00f6f260a3d56c554787ef0944e26d79251da", + "reference": "0db00f6f260a3d56c554787ef0944e26d79251da", "shasum": "" }, "require": { @@ -89,7 +89,6 @@ "phpro/grumphp-shim": "^2.2", "phpunit/phpunit": "^9 || ^10" }, - "default-branch": true, "type": "composer-plugin", "extra": { "class": "Acquia\\Drupal\\RecommendedSettings\\Plugin" @@ -118,9 +117,9 @@ "support": { "docs": "https://docs.acquia.com/drupal-recommended-settings/", "issues": "https://github.com/acquia/drupal-recommended-settings/issues", - "source": "https://github.com/acquia/drupal-recommended-settings/tree/develop" + "source": "https://github.com/acquia/drupal-recommended-settings/tree/ACMS-3508" }, - "time": "2023-11-21T12:48:07+00:00" + "time": "2024-01-22T10:38:33+00:00" }, { "name": "asm89/stack-cors", diff --git a/settings/config.settings.php b/settings/config.settings.php deleted file mode 100644 index ee26fe158..000000000 --- a/settings/config.settings.php +++ /dev/null @@ -1,73 +0,0 @@ - $status) { - $config["$split_filename_prefix.$split_env"]['status'] = $status; -} - -/** - * Set multisite split. - */ -/** - * Site path. - * - * @var string $site_path - * This is always set and exposed by the Drupal Kernel. - */ -// phpcs:ignore -$site_name = EnvironmentDetector::getSiteName($site_path); -// phpcs:ignore -$config["$split_filename_prefix.$site_name"]['status'] = TRUE; - -// Set acsf site split if explicit global exists. -global $_acsf_site_name; -if (isset($_acsf_site_name)) { - $config["$split_filename_prefix.$_acsf_site_name"]['status'] = TRUE; -} diff --git a/src/Robo/Commands/Blt/MigrateToDrsCommand.php b/src/Robo/Commands/Blt/MigrateToDrsCommand.php index c98429562..aa0f78b8f 100644 --- a/src/Robo/Commands/Blt/MigrateToDrsCommand.php +++ b/src/Robo/Commands/Blt/MigrateToDrsCommand.php @@ -63,12 +63,12 @@ class MigrateToDrsCommand extends BltTasks { /** * Blt config override variable. */ - private string $bltConfigOverrideVar = '$blt_override_config_directories'; + private string $bltConfigOverrideVar = 'blt_override_config_directories'; /** * Drs config override variable. */ - private string $drsConfigOverrideVar = '$drs_override_config_directories'; + private string $drsConfigOverrideVar = 'drs_override_config_directories'; /** * Migrate BLT to use DRS. @@ -114,7 +114,7 @@ private function processSettingsFile(string $site): void { "$sitePath/settings.php", "$sitePath/settings/local.settings.php", "$sitePath/settings/default.local.settings.php", - ] + ]; $filesystem = new Filesystem(); foreach ($relativePaths as $relativePath) { if ($filesystem->exists($relativePath)) { @@ -132,17 +132,20 @@ private function processSettingsFile(string $site): void { */ private function updateSettingsFile(string $settingFile): void { $fileContent = file_get_contents($settingFile); + + // Check whether $blt_override_config_directories variable exists. + if (str_contains($fileContent, $this->bltConfigOverrideVar)) { + $fileContent = str_replace($this->bltConfigOverrideVar, $this->drsConfigOverrideVar, $fileContent); + } // Let remove BLT require section from settings.php. - $settingsFileContent = str_replace($this->bltSettingsWarning, '', $fileContent); if (substr_count($fileContent, $this->drsSettingsWarning) < 1) { - $settingsFileContent = str_replace($this->bltSettingsWarning, $this->drsSettingsWarning, $fileContent); + $fileContent = str_replace($this->bltSettingsWarning, $this->drsSettingsWarning, $fileContent); } - // Check whether $blt_override_config_directories variable exists. - if (substr_count($settingsFileContent, $this->bltConfigOverrideVar) < 1) { - $settingsFileContent = str_replace($this->bltConfigOverrideVar, $this->drsConfigOverrideVar, $settingsFileContent); + else { + $fileContent = str_replace($this->bltSettingsWarning, '', $fileContent); } - file_put_contents($settingFile, $settingsFileContent); + file_put_contents($settingFile, $fileContent); } /**