Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
// Created at: 2018-02-08 13:07:15
/**
* Added by Pantheon Migration Tool.
* Includes Pantheon-specific configs.
*/
/**
* Helpers
*/
$cli = (php_sapi_name() === 'cli');
/**
* Pantheon-specific settings
*/
if (!defined('PANTHEON_ENVIRONMENT')) {
/**
* Database settings:
*
* The $databases array specifies the database connection or
* connections that Drupal may use. Drupal is able to connect
* to multiple databases, including multiple types of databases,
* during the same request.
*
* One example of the simplest connection array is shown below. To use the
* sample settings, copy and uncomment the code below between the @code and
* @endcode lines and paste it after the $databases declaration. You will need
* to replace the database username and password and possibly the host and port
* with the appropriate credentials for your database system.
*
* The next section describes how to customize the $databases array for more
* specific needs.
*
* @code
* $databases['default']['default'] = array (
* 'database' => 'databasename',
* 'username' => 'sqlusername',
* 'password' => 'sqlpassword',
* 'host' => 'localhost',
* 'port' => '3306',
* 'driver' => 'mysql',
* 'prefix' => '',
* 'collation' => 'utf8mb4_general_ci',
* );
* @endcode
*/
$databases['default']['default'] = array (
'database' => 'd8demo',
'username' => 'd8demo_user',
'password' => 'd8demo_pass',
'host' => 'localhost',
'port' => '3306',
'driver' => 'mysql',
'prefix' => '',
'collation' => 'utf8mb4_general_ci',
);
$settings['hash_salt'] = 'lol';
$settings['pantheon_binding'] = 'localdev';
$pressflow_settings = array(
"databases" => $databases,
"conf" => $settings,
);
$_SERVER['PRESSFLOW_SETTINGS'] = json_encode($pressflow_settings);
$simplesamlphp_dir = DRUPAL_ROOT . "/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php";
$settings['simplesamlphp_dir'] = $simplesamlphp_dir;
require_once($simplesamlphp_dir);
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
} else if (PANTHEON_ENVIRONMENT == 'lando') {
# Force SSL
if(isset($_SERVER['HTTP_X_FORWARDED_PORT']) && $_SERVER['HTTP_X_FORWARDED_PORT'] == '80') {
header('HTTP/1.0 301 Moved Permanently');
header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
ini_set('html_errors', TRUE);
$conf['error_level'] = 2;
$settings['error_level'] = 2;
if(!empty($_SERVER['LANDO_WEBROOT'])) {
$_ENV['HOME'] = $_SERVER['LANDO_WEBROOT'];
$_SERVER['HOME'] = $_SERVER['LANDO_WEBROOT'];
//error_log('set home dir: ' . $_ENV['HOME']);
}
else {
die("pantheon environment is lando but LANDO_WEBROOT isn't set");
}
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;
$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
$settings['extension_discovery_scan_tests'] = TRUE;
}
// If necessary, force redirect in to https
if (isset($variables)) {
if (array_key_exists('https', $variables) && $variables['https']) {
if (!$cli && $_SERVER['HTTPS'] === 'OFF') {
if (!isset($_SERVER['HTTP_X_SSL']) || (isset($_SERVER['HTTP_X_SSL']) && $_SERVER['HTTP_X_SSL'] != 'ON')) {
header('HTTP/1.0 301 Moved Permanently');
header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
}
}
}
// Set possible redis module paths.
$redis_paths = array(
implode(DIRECTORY_SEPARATOR, array('sites', 'default', 'modules', 'contrib', 'redis')),
implode(DIRECTORY_SEPARATOR, array('sites', 'default', 'modules', 'redis')),
implode(DIRECTORY_SEPARATOR, array('modules', 'contrib', 'redis')),
implode(DIRECTORY_SEPARATOR, array('modules', 'redis')),
);
if (array_key_exists('CACHE_HOST', $_ENV) && !empty($_ENV['CACHE_HOST'])) {
foreach ($redis_paths as $path) {
$directory = __DIR__ . DIRECTORY_SEPARATOR . $path;
if (is_dir($directory)) {
if (in_array('example.services.yml', scandir($directory))) {
$settings['container_yamls'][] = $directory . DIRECTORY_SEPARATOR . 'example.services.yml';
$settings['redis.connection']['interface'] = 'PhpRedis';
$settings['redis.connection']['host'] = $_ENV['CACHE_HOST'];
$settings['redis.connection']['port'] = $_ENV['CACHE_PORT'];
$settings['redis.connection']['password'] = $_ENV['CACHE_PASSWORD'];
$settings['cache']['default'] = 'cache.backend.redis';
$settings['cache_prefix']['default'] = 'pantheon-redis';
$settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['discovery'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['config'] = 'cache.backend.chainedfast';
break;
}
}
}
}
if (PANTHEON_ENVIRONMENT != 'live') {
// Place for settings for the non-live environment
}
if (PANTHEON_ENVIRONMENT == 'dev') {
// Place for settings for the dev environment
}
if (PANTHEON_ENVIRONMENT == 'test') {
// Place for settings for the test environment
}
if (PANTHEON_ENVIRONMENT == 'live') {
// Place for settings for the live environment
// Redirect to canonical domain
if (isset($variables)) {
if (isset($variables['domains']['canonical'])) {
if (!$cli) {
$location = false;
// Check www sub-domain
$www = substr($_SERVER['HTTP_HOST'], 0, 4) === 'www.';
// Get current protocol
$protocol = 'http';
if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) {
$protocol = 'https';
}
// Collect all allowed domain names
$domains = array(
$variables['domains']['canonical'],
"live-{$_ENV['PANTHEON_SITE_NAME']}.pantheonsite.io"
);
if (isset($variables['domains']['additional']) && is_array($variables['domains']['additional'])) {
$domains = is_array($variables['domains']['additional']) ? array_merge($domains, $variables['domains']['additional']) : array_merge($domains, array($variables['domains']['additional']));
}
// Default redirect
$redirect = "$protocol://{$variables['domains']['canonical']}{$_SERVER['REQUEST_URI']}";
if ($www) {
if (substr($variables['domains']['canonical'], 0, 4) === 'www.') {
$redirect = false;
}
} else {
if (substr($variables['domains']['canonical'], 0, 4) !== 'www.') {
$redirect = false;
}
}
if (in_array($_SERVER['HTTP_HOST'], $domains)) {
$redirect = false;
}
if ($redirect) {
header("HTTP/1.0 301 Moved Permanently");
header("Location: $redirect");
exit();
}
}
}
}
}
foreach (array('dev', 'test', 'live') as $environment) {
if (isset($variables['environments'][$environment]['conf']) && is_array($variables['environments'][$environment]['conf'])) {
foreach ($variables['environments'][$environment]['conf'] as $variable => $value) {
$conf[$variable] = $value;
}
}
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . "files/private/settings/$environment.settings.php")) {
require_once __DIR__ . DIRECTORY_SEPARATOR . "files/private/settings/$environment.settings.php";
}
}