From 693801eb3fb7d803f9a291a2e9c11295e267d7eb Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Mon, 1 Oct 2018 14:29:44 +0200 Subject: [PATCH] OPENEUROPA-1149: Update the syntax and add documentation block. --- src/Commands/DrupalCommands.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) 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'), ]); }