Skip to content

Commit

Permalink
ACMS-1890: Updating blt_override_config_directories to drs_override_c…
Browse files Browse the repository at this point in the history
…onfig_directories in settings file.
  • Loading branch information
apathak18 authored and chandan-singh7929 committed Mar 15, 2024
1 parent 0e41a69 commit 292e373
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion settings/config.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
global $_acsf_site_name;
if (isset($_acsf_site_name)) {
$config["$split_filename_prefix.$_acsf_site_name"]['status'] = TRUE;
}
}
18 changes: 16 additions & 2 deletions src/Robo/Commands/Blt/MigrateToDrsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ class MigrateToDrsCommand extends BltTasks {
*/
private string $drsUseStmt = 'use Acquia\Drupal\RecommendedSettings\Helpers\EnvironmentDetector;';

/**
* Blt config override variable.
*/
private string $bltConfigOverrideVar = '$blt_override_config_directories';

/**
* Drs config override variable.
*/
private string $drsConfigOverrideVar = '$drs_override_config_directories';

/**
* Migrate BLT to use DRS.
*
Expand All @@ -73,6 +83,7 @@ public function migrateDrs(): void {
$this->io()->warning('This script will update settings.php and local.settings.php files from site [' . implode(',', $multiSites) . '] with following changes.');
$this->io()->table(['File', 'Snippet to remove', 'Snippet to add'], [
['settings.php', $this->bltSettingsWarning, $this->drsSettingsWarning],
['settings.php', $this->bltConfigOverrideVar, $this->drsConfigOverrideVar],
['local.settings.php', $this->bltUseStmt, $this->drsUseStmt],
]);
}
Expand Down Expand Up @@ -121,14 +132,17 @@ private function processSettingsFile(string $site): void {
*/
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) {
$settingsFileContent = 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);
}

file_put_contents($settingFile, $fileContent);
file_put_contents($settingFile, $settingsFileContent);
}

/**
Expand Down

0 comments on commit 292e373

Please sign in to comment.