Skip to content

Commit

Permalink
OPENEUROPA-1149: Update the syntax and add documentation block.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Oct 1, 2018
1 parent e80c0ab commit 5630d84
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/Commands/DrupalCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);
}
Expand Down

0 comments on commit 5630d84

Please sign in to comment.