Skip to content

Commit

Permalink
Update settings. Merge pull request #64 from backdrop-ops/update-sett…
Browse files Browse the repository at this point in the history
…ings

Fixes #58, #62, #46, and #34.
  • Loading branch information
herbdool authored Apr 2, 2022
2 parents eb0cdbd + eabbf9f commit 83ab755
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 22 deletions.
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Ignore this file so it can be changed.
.gitignore
# Pantheon commits a settings.php for environment-specific settings.
# Place local settings in settings.local.php
/settings.local.php

# Ignore configuration files that may contain sensitive information.
/settings*.php
sites/*/settings*.php
# Avoid accidental modification of pantheon.upstream.yml in sites
# created from this upstream.
pantheon.upstream.yml

# Ignore paths that contain user-generated content.
/files
Expand Down
88 changes: 88 additions & 0 deletions settings.pantheon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

/**
* @file
* Pantheon configuration file.
*
* IMPORTANT NOTE:
* Do not modify this file. This file is maintained by Backdrop Pantheon
* upstream.
*
* @see: https://github.com/backdrop-ops/backdrop-pantheon
*
* Site-specific modifications belong in settings.php, not this file. This file
* may change in future releases and modifications would cause conflicts when
* attempting to apply upstream updates.
*/

/**
* Version of Pantheon files.
*
* This is a monotonically-increasing sequence number that is
* incremented whenever a change is made to any Pantheon file.
* Not changed if Backdrop core is updated without any change to
* any Pantheon file.
*
* The Pantheon version is included in the git tag only if a
* release is made that includes changes to Pantheon files, but
* not to any Backdrop files.
*/
if (!defined("PANTHEON_VERSION")) {
define("PANTHEON_VERSION", "1");
}

/**
* Pantheon environment variables.
*
* See https://github.com/backdrop-ops/backdrop-pantheon/issues/58
*/
if (isset($_SERVER['PRESSFLOW_SETTINGS'])) {
$pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE);
$pressflow_settings['settings'] = $pressflow_settings['conf'];
$_SERVER['PRESSFLOW_SETTINGS'] = json_encode($pressflow_settings);
$_SERVER['BACKDROP_SETTINGS'] = $_SERVER['PRESSFLOW_SETTINGS'];
}

/**
* Define appropriate location for tmp directory
*
* Issue: https://github.com/backdrop-ops/backdrop-pantheon/issues/34
*
*/
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
$config['system.core']['file_temporary_path'] = sys_get_temp_dir();
}

/**
* Handle Hash Salt Value on Pantheon.
*
* Issue: https://github.com/backdrop-ops/backdrop-pantheon/issues/62
*/
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
if (isset($_ENV['HASH_SALT'])) {
$settings['hash_salt'] = $_ENV['HASH_SALT'];
}
elseif (isset($_ENV['DRUPAL_HASH_SALT'])) {
$settings['hash_salt'] = $_ENV['DRUPAL_HASH_SALT'];
}
}

/**
* Define appropriate location for public file directory, and
* private file directory (optional).
*/
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
$config['system.core']['file_public_path'] = 'files';
// $config['system.core']['file_private_path'] = 'files/private';
}

/**
* "Trusted host settings" are not necessary on Pantheon; traffic will only
* be routed to your site if the host settings match a domain configured for
* your site in the dashboard.
*
* Issue: https://github.com/backdrop-ops/backdrop-pantheon/issues/46
*/
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
$settings['trusted_host_patterns'][] = '.*';
}
27 changes: 10 additions & 17 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@
*/
// $settings['trusted_host_patterns'] = array('^www\.example\.com$');

if (defined('PANTHEON_ENVIRONMENT')) {
if (in_array($_ENV['PANTHEON_ENVIRONMENT'], array('dev', 'test', 'live'))) {
$settings['trusted_host_patterns'][] = "{$_ENV['PANTHEON_ENVIRONMENT']}-{$_ENV['PANTHEON_SITE_NAME']}.pantheon.io";
$settings['trusted_host_patterns'][] = "{$_ENV['PANTHEON_ENVIRONMENT']}-{$_ENV['PANTHEON_SITE_NAME']}.pantheonsite.io";
}
}

/**
* Base URL (optional).
*
Expand Down Expand Up @@ -444,6 +437,16 @@
*/
//$config['system.core']['block_interest_cohort'] = FALSE;

/**
* Include the Pantheon-specific settings file.
*
* The settings.pantheon.php file makes some changes that affect all
* environments that this site exists in. Always include this file, even in
* a local development environment, to insure that the site settings remain
* consistent.
*/
include __DIR__ . "/settings.pantheon.php";

/**
* Include a local settings file, if available.
*
Expand All @@ -465,13 +468,3 @@
if (file_exists(__DIR__ . '/settings.local.php')) {
include __DIR__ . '/settings.local.php';
}

/**
* Pantheon specific compatibility.
*
* Override the database information to pass the correct Database credentials
* directly from Pantheon to Backdrop.
*/
if (isset($_SERVER['PRESSFLOW_SETTINGS'])) {
$_SERVER['BACKDROP_SETTINGS'] = $_SERVER['PRESSFLOW_SETTINGS'];
}

0 comments on commit 83ab755

Please sign in to comment.