From 80270eca1cb6db2137d203ffc0baa957fb930d6b Mon Sep 17 00:00:00 2001 From: Greg Anderson Date: Mon, 17 Aug 2015 17:06:59 -0700 Subject: [PATCH] Pantheon settings.php files. pantheon-systems/drops-8#55. --- sites/default/settings.pantheon.php | 94 +++++++++++++++++++++++++++++ sites/default/settings.php | 20 ++++++ 2 files changed, 114 insertions(+) create mode 100644 sites/default/settings.pantheon.php create mode 100755 sites/default/settings.php diff --git a/sites/default/settings.pantheon.php b/sites/default/settings.pantheon.php new file mode 100644 index 000000000..1e04f018c --- /dev/null +++ b/sites/default/settings.pantheon.php @@ -0,0 +1,94 @@ + 'sites/default/files', + CONFIG_STAGING_DIRECTORY => 'sites/default/files', + ); +} +else { + $config_directories = array( + CONFIG_ACTIVE_DIRECTORY => 'sites/default/files/config/active', + CONFIG_STAGING_DIRECTORY => 'sites/default/config', + ); +} + +/** + * Override the $install_state variable to let Drupal know that the settings are verified + * since they are being passed directly by the Pantheon. + * + * Issue: https://github.com/pantheon-systems/drops-8/issues/9 + * + */ +if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { + $GLOBALS['install_state']['settings_verified'] = TRUE; +} + +/** + * Allow Drupal 8 to Cleanly Redirect to Install.php For New Sites. + * + * Issue: https://github.com/pantheon-systems/drops-8/issues/3 + * + * c.f. https://github.com/pantheon-systems/drops-8/pull/53 + * + */ +if (isset($_ENV['PANTHEON_ENVIRONMENT']) && (substr($_SERVER['SCRIPT_NAME'],0,17) != '/core/install.php') && (!is_dir(__DIR__ . '/files/styles'))) { + include_once __DIR__ . '/../../core/includes/install.inc'; + install_goto('core/install.php'); +} + +/** + * Override the $databases variable to pass the correct Database credentials + * directly from Pantheon to Drupal. + * + * Issue: https://github.com/pantheon-systems/drops-8/issues/8 + * + */ +if (isset($_SERVER['PRESSFLOW_SETTINGS'])) { + $pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE); + foreach ($pressflow_settings as $key => $value) { + // One level of depth should be enough for $conf and $database. + if ($key == 'conf') { + foreach($value as $conf_key => $conf_value) { + $conf[$conf_key] = $conf_value; + } + } + elseif ($key == 'databases') { + // Protect default configuration but allow the specification of + // additional databases. Also, allows fun things with 'prefix' if they + // want to try multisite. + if (!isset($databases) || !is_array($databases)) { + $databases = array(); + } + $databases = array_replace_recursive($databases, $value); + } + else { + $$key = $value; + } + } +} + +/** + * Handle Hash Salt Value from Drupal + * + * Issue: https://github.com/pantheon-systems/drops-8/issues/10 + * + */ +if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { + $settings['hash_salt'] = $_ENV['DRUPAL_HASH_SALT']; +} + + diff --git a/sites/default/settings.php b/sites/default/settings.php new file mode 100755 index 000000000..fbc1e688a --- /dev/null +++ b/sites/default/settings.php @@ -0,0 +1,20 @@ +