Skip to content

Commit 91cee7f

Browse files
Added support for config.local.php, databases.local.php & settings.local.php files. Added MAILGUN_URL support. Updating change log.
1 parent b1e6116 commit 91cee7f

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
44

55
## [Unreleased][unreleased]
66

7+
## [0.1.15] - 2022-01-25
8+
9+
### Changed
10+
11+
- Added support for `config.local.php`, `databases.local.php` & `settings.local.php` files.
12+
- Added `MAILGUN_URL` support.
13+
714
## [0.1.14] - 2022-01-21
815

916
### Changed
1017

11-
- Added TRUSTED_HOST_PATTERNS support.
18+
- Added `TRUSTED_HOST_PATTERNS` support.
1219

1320
## [0.1.13] - 2022-01-20
1421

@@ -107,7 +114,8 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
107114

108115
**Initial release!**
109116

110-
[unreleased]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.14...main
117+
[unreleased]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.15...main
118+
[0.1.15]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.14...0.1.15
111119
[0.1.14]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.13...0.1.14
112120
[0.1.13]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.12...0.1.13
113121
[0.1.12]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.11...0.1.12

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ configuration.
113113
* [FILE_TEMP_PATH](#file_temp_path)
114114
* [CONFIG_SYNC_PATH](#config_sync_path)
115115
* [DOMAINS](#domains)
116+
* [MAILGUN_URL](#mailgun_url)
116117
* [SHIELD](#shield)
117118
* [SHIELD_USERNAME](#shield_username)
118119
* [SHIELD_PASSWORD](#shield_password)
@@ -178,9 +179,26 @@ A CSV list of domains used by the given environment:
178179
DOMAINS=foo.example,bar.example,baz.example
179180
```
180181

182+
#### MAILGUN_URL
183+
The information Drupal should use to authenticate with the Mailgun API.
184+
185+
The "user" in the [DSN](https://en.wikipedia.org/wiki/Data_source_name) is the API key.
186+
187+
##### US URL Example
188+
```dotenv
189+
MAILGUN_URL=https://[email protected]
190+
```
191+
192+
##### EU URL Example
193+
```dotenv
194+
MAILGUN_URL=https://[email protected]
195+
```
196+
181197
#### SHIELD
182198
A boolean allowing the enabling/disabling of Shield module auth functionality.
183199

200+
Note: _Make sure the "Enable Shield" checkbox is checked in Drupal & that config is committed._
201+
184202
##### SHIELD_USERNAME
185203
The username for Shield to require, if enabled.
186204

src/Dotenv.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ private function alter(&$data, $type): void
8888
$$type = &$data;
8989

9090
// Allow alteration via the `default` directory.
91-
$file = DRUPAL_ROOT . '/sites/default/' .
92-
$type . '.' . $this->getEnvironmentName() . '.php';
93-
if (file_exists($file)) {
94-
include $file;
95-
}
91+
$files[] = DRUPAL_ROOT . '/sites/default/' . $type . '.' . $this->getEnvironmentName() . '.php';
92+
$files[] = DRUPAL_ROOT . '/sites/default/' . $type . '.local.php';
9693

9794
// Allow alteration via non-`default` directories.
9895
$siteName = $this->getSiteName();
9996
if ($siteName !== 'default') {
100-
$file = DRUPAL_ROOT . '/sites/' . $siteName . '/' .
101-
$type . '.' . $this->getEnvironmentName() . '.php';
97+
$files[] = DRUPAL_ROOT . '/sites/' . $siteName . '/' . $type . '.' . $this->getEnvironmentName() . '.php';
98+
$files[] = DRUPAL_ROOT . '/sites/' . $siteName . '/' . $type . '.local.php';
99+
}
100+
101+
foreach ($files as $file) {
102102
if (file_exists($file)) {
103103
include $file;
104104
}
@@ -159,6 +159,16 @@ public function getConfig(): array
159159
break;
160160
}
161161

162+
// Configure Mailgun.
163+
if (isset($_SERVER['MAILGUN_URL'])) {
164+
$parts = parse_url($_SERVER['MAILGUN_URL']);
165+
$config['mailgun.settings']['api_endpoint'] = vsprintf('%s://%s', [
166+
'scheme' => $parts['scheme'] ?? 'https',
167+
'host' => $parts['host'] ?? 'api.mailgun.net',
168+
]);
169+
$config['mailgun.settings']['api_key'] = $parts['name'] ?? 'key-1234567890abcdefghijklmnopqrstu';
170+
}
171+
162172
// Configure Shield if enabled.
163173
if ($config['shield.settings']['shield_enable']) {
164174
if (isset($_SERVER['SHIELD_USERNAME'])) {

0 commit comments

Comments
 (0)