diff --git a/src/Commands/DrupalCommands.php b/src/Commands/DrupalCommands.php index 9fedb934..7e67ceb2 100644 --- a/src/Commands/DrupalCommands.php +++ b/src/Commands/DrupalCommands.php @@ -297,13 +297,27 @@ public function settingsSetup(array $options = [ $settings_path = $options['root'] . '/sites/' . $options['sites-subdir'] . '/settings.php'; $settings_override_path = $options['root'] . '/sites/' . $options['sites-subdir'] . '/' . $options['settings-override-file']; + // Save the filename of the override file in a single variable to use it + // in the heredoc variable $custom_config hereunder. + $settings_override_filename = $options['settings-override-file']; + + $custom_config = <<< EOF +/** + * Load override configuration, if available. + * + * This file is generated by the openeuropa/task-runner package. + * Use $settings_override_filename to override variables. + * + * Keep this code block at the end of this file to take full effect. + */ +if (file_exists(\$app_root . '/' . \$site_path . '/' . $settings_override_filename)) { + include \$app_root . '/' . \$site_path . '/' . $settings_override_filename; +} +EOF; + return $this->collectionBuilder()->addTaskList([ $this->taskFilesystemStack()->copy($settings_default_path, $settings_path, (bool) $options['force']), - $this->taskWriteToFile($settings_path)->append()->lines([ - "if (file_exists(\$app_root . '/' . \$site_path . '/" . $options['settings-override-file'] . "')) {", - " include \$app_root . '/' . \$site_path . '/" . $options['settings-override-file'] . "';", - "}" - ]), + $this->taskWriteToFile($settings_path)->append()->lines([$custom_config]), $this->taskWriteConfiguration($settings_override_path, $this->getConfig())->setConfigKey('drupal.settings'), ]); }