diff --git a/composer.lock b/composer.lock index 450cf1052..647b7de2c 100644 --- a/composer.lock +++ b/composer.lock @@ -84,9 +84,9 @@ "require-dev": { "acquia/coding-standards": "^2.0", "composer/composer": "^2.2", - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", "ergebnis/composer-normalize": "^2.30.2", - "phpro/grumphp-shim": "^1.5", + "phpro/grumphp-shim": "^2.2", "phpunit/phpunit": "^9 || ^10" }, "default-branch": true, diff --git a/settings/config.settings.php b/settings/config.settings.php new file mode 100644 index 000000000..cc9347153 --- /dev/null +++ b/settings/config.settings.php @@ -0,0 +1,73 @@ + $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; +} \ No newline at end of file diff --git a/src/Robo/Commands/Blt/MigrateToDrsCommand.php b/src/Robo/Commands/Blt/MigrateToDrsCommand.php index 36ea512b7..b17d9cf42 100644 --- a/src/Robo/Commands/Blt/MigrateToDrsCommand.php +++ b/src/Robo/Commands/Blt/MigrateToDrsCommand.php @@ -98,16 +98,18 @@ private function processSettingsFile(string $site): void { $root = $this->getConfigValue('docroot'); $sitePath = Path::join($root, 'sites/' . $site); - // Update settings file content. + // Relative paths of settings.php file. + $relativePaths = [ + "$sitePath/settings.php", + "$sitePath/settings/local.settings.php", + "$sitePath/settings/default.local.settings.php", + ] $filesystem = new Filesystem(); - if ($filesystem->exists($sitePath . '/settings.php')) { - $this->updateSettingsFile($sitePath . '/settings.php'); - } - if ($filesystem->exists($sitePath . '/settings/local.settings.php')) { - $this->updateLocalSettingsFile($sitePath . '/settings/local.settings.php'); - } - if ($filesystem->exists($sitePath . '/settings/default.local.settings.php')) { - $this->updateLocalSettingsFile($sitePath . '/settings/default.local.settings.php'); + foreach ($relativePaths as $relativePath) { + if ($filesystem->exists($relativePath)) { + // Update settings file content. + $this->updateSettingsFile($relativePath); + } } } @@ -121,12 +123,11 @@ private function updateSettingsFile(string $settingFile): void { $fileContent = file_get_contents($settingFile); // Let remove BLT require section from settings.php. + $settingsFileContent = str_replace($this->bltSettingsWarning, '', $fileContent); if (substr_count($fileContent, $this->drsSettingsWarning) < 1) { - $fileContent = str_replace($this->bltSettingsWarning, $this->drsSettingsWarning, $fileContent); - } - else { - $fileContent = str_replace($this->bltSettingsWarning, '', $fileContent); + $settingsFileContent = str_replace($this->bltSettingsWarning, $this->drsSettingsWarning, $fileContent); } + file_put_contents($settingFile, $fileContent); }