-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
settings.php
201 lines (167 loc) · 7.06 KB
/
settings.php
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
<?php
/**
* @file
* Drupal site-specific configuration file.
*
* The structure of this file:
* - Environment constants definitions.
* - Site-specific settings.
* - Inclusion of hosting providers settings.
* - Per-environment overrides.
* - Inclusion of local settings.
*
* Create settings.local.php file to include local settings overrides.
*
* phpcs:disable Drupal.Commenting.InlineComment.NoSpaceBefore
* phpcs:disable Drupal.Commenting.InlineComment.SpacingAfter
* phpcs:disable DrupalPractice.Commenting.CommentEmptyLine.SpacingAfter
* phpcs:disable DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
*/
declare(strict_types=1);
////////////////////////////////////////////////////////////////////////////////
/// ENVIRONMENT CONSTANTS ///
////////////////////////////////////////////////////////////////////////////////
// Use these constants anywhere in code to alter behaviour for a specific
// environment.
// @codeCoverageIgnoreStart
if (!defined('ENVIRONMENT_LOCAL')) {
define('ENVIRONMENT_LOCAL', 'local');
}
if (!defined('ENVIRONMENT_CI')) {
define('ENVIRONMENT_CI', 'ci');
}
if (!defined('ENVIRONMENT_PROD')) {
define('ENVIRONMENT_PROD', 'prod');
}
if (!defined('ENVIRONMENT_TEST')) {
define('ENVIRONMENT_TEST', 'test');
}
if (!defined('ENVIRONMENT_DEV')) {
define('ENVIRONMENT_DEV', 'dev');
}
// @codeCoverageIgnoreEnd
$settings['environment'] = empty(getenv('CI')) ? ENVIRONMENT_LOCAL : ENVIRONMENT_CI;
////////////////////////////////////////////////////////////////////////////////
/// SITE-SPECIFIC SETTINGS ///
////////////////////////////////////////////////////////////////////////////////
$app_root = $app_root ?? DRUPAL_ROOT;
$site_path = $site_path ?? 'sites/default';
$contrib_path = $app_root . DIRECTORY_SEPARATOR . (is_dir($app_root . DIRECTORY_SEPARATOR . 'modules/contrib') ? 'modules/contrib' : 'modules');
// Load services definition file.
$settings['container_yamls'][] = $app_root . '/' . $site_path . '/services.yml';
// Location of the site configuration files.
$settings['config_sync_directory'] = getenv('DRUPAL_CONFIG_PATH') ?: '../config/default';
// Private directory.
$settings['file_private_path'] = getenv('DRUPAL_PRIVATE_FILES') ?: 'sites/default/files/private';
// Temporary directory.
$settings['file_temp_path'] = getenv('DRUPAL_TEMPORARY_FILES') ?: '/tmp';
// Base salt on the DB host name.
$settings['hash_salt'] = hash('sha256', getenv('MARIADB_HOST') ?: 'localhost');
// Expiration of cached pages.
$config['system.performance']['cache']['page']['max_age'] = 900;
// Aggregate CSS and JS files.
$config['system.performance']['css']['preprocess'] = TRUE;
$config['system.performance']['js']['preprocess'] = TRUE;
// The default list of directories that will be ignored by Drupal's file API.
$settings['file_scan_ignore_directories'] = [
'node_modules',
'bower_components',
];
// The default number of entities to update in a batch process.
$settings['entity_update_batch_size'] = 50;
// Trusted Host Patterns.
// Settings for other environments are included below.
// If your site runs on multiple domains, you need to add these domains here.
// escape dots, remove schema, use commas as regex separator.
// See https://www.drupal.org/node/2410395 for more information.
$settings['trusted_host_patterns'] = [
// Local URL.
'^.+\.docker\.amazee\.io$',
// URL when accessed from Behat tests.
'^nginx$',
];
// Modules excluded from config export.
$settings['config_exclude_modules'] = [];
ini_set('date.timezone', 'Australia/Melbourne');
date_default_timezone_set('Australia/Melbourne');
// Maintenance theme.
$config['maintenance_theme'] = 'your_site_theme';
// Default database configuration.
$databases = [
'default' =>
[
'default' =>
[
'database' => getenv('MARIADB_DATABASE') ?: 'drupal',
'username' => getenv('MARIADB_USERNAME') ?: 'drupal',
'password' => getenv('MARIADB_PASSWORD') ?: 'drupal',
'host' => getenv('MARIADB_HOST') ?: 'localhost',
'port' => getenv('MARIADB_PORT') ?: '',
'prefix' => '',
'driver' => 'mysql',
],
],
];
////////////////////////////////////////////////////////////////////////////////
/// ENVIRONMENT DETECTION ///
////////////////////////////////////////////////////////////////////////////////
// Load environment-specific settings.
if (file_exists($app_root . '/' . $site_path . '/includes/providers')) {
$files = glob($app_root . '/' . $site_path . '/includes/providers/settings.*.php');
if ($files) {
foreach ($files as $filename) {
require $filename;
}
}
}
// Allow overriding of an environment type.
if (!empty(getenv('DRUPAL_ENVIRONMENT'))) {
$settings['environment'] = getenv('DRUPAL_ENVIRONMENT');
}
////////////////////////////////////////////////////////////////////////////////
/// ENVIRONMENT-SPECIFIC SETTINGS ///
////////////////////////////////////////////////////////////////////////////////
if ($settings['environment'] == ENVIRONMENT_CI) {
// Never harden permissions on sites/default/files.
$settings['skip_permissions_hardening'] = TRUE;
// Disable built-in cron trigger.
$config['automated_cron.settings']['interval'] = 0;
// Disable mail send out.
$settings['suspend_mail_send'] = TRUE;
}
if ($settings['environment'] == ENVIRONMENT_LOCAL) {
// Never harden permissions on sites/default/files during local development.
$settings['skip_permissions_hardening'] = TRUE;
// Disable built-in cron trigger.
$config['automated_cron.settings']['interval'] = 0;
// Show all error messages on the site.
$config['system.logging']['error_level'] = 'all';
}
////////////////////////////////////////////////////////////////////////////////
/// PER-MODULE SETTINGS ///
////////////////////////////////////////////////////////////////////////////////
if (file_exists($app_root . '/' . $site_path . '/includes/modules')) {
$files = glob($app_root . '/' . $site_path . '/includes/modules/settings.*.php');
if ($files) {
foreach ($files as $filename) {
require $filename;
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// LOCAL SETTINGS ///
////////////////////////////////////////////////////////////////////////////////
// Load local development override configuration, if available.
//
// Copy default.settings.local.php and default.services.local.yml to
// settings.local.php and services.local.yml respectively.
//
// Keep this code block at the end of this file to take full effect.
// @codeCoverageIgnoreStart
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
require $app_root . '/' . $site_path . '/settings.local.php';
}
if (file_exists($app_root . '/' . $site_path . '/services.local.yml')) {
$settings['container_yamls'][] = $app_root . '/' . $site_path . '/services.local.yml';
}
// @codeCoverageIgnoreEnd