Skip to content

Commit

Permalink
ACMS-1890: PR feedback for drs config override.
Browse files Browse the repository at this point in the history
  • Loading branch information
apathak18 authored and chandan-singh7929 committed Mar 15, 2024
1 parent 292e373 commit d92b77d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 91 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 7 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 0 additions & 73 deletions settings/config.settings.php

This file was deleted.

21 changes: 12 additions & 9 deletions src/Robo/Commands/Blt/MigrateToDrsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit d92b77d

Please sign in to comment.