-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPantheon.php
More file actions
59 lines (49 loc) · 1.35 KB
/
Pantheon.php
File metadata and controls
59 lines (49 loc) · 1.35 KB
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
<?php
declare(strict_types=1);
namespace DrevOps\EnvironmentDetector\Providers;
use DrevOps\EnvironmentDetector\Environment;
/**
* Pantheon provider.
*
* Detects the Pantheon environment type.
*
* @package DrevOps\EnvironmentDetector\Providers
*/
class Pantheon extends AbstractProvider {
/**
* {@inheritdoc}
*/
public const ID = 'pantheon';
/**
* {@inheritdoc}
*/
public const LABEL = 'Pantheon';
/**
* {@inheritdoc}
*/
protected function envPrefixes(): array {
return ['PANTHEON_', 'TERMINUS_'];
}
/**
* {@inheritdoc}
*/
public function active(): bool {
// Some local development environments may inject the PANTHEON_ENVIRONMENT.
// @see https://docs.lando.dev/plugins/pantheon/v/v1.8.0/environment.html
return getenv('PANTHEON_ENVIRONMENT') !== FALSE && !in_array(getenv('PANTHEON_ENVIRONMENT'), ['ddev', 'lando'], TRUE);
}
/**
* {@inheritdoc}
*/
public function type(): ?string {
// @todo Review this implementation as some implementations may consider
// 'dev', 'test' and 'live' as being the 'production' environment from the
// perspective of the application.
return match (getenv('PANTHEON_ENVIRONMENT')) {
'dev' => Environment::DEVELOPMENT,
'test' => Environment::STAGE,
'live' => Environment::PRODUCTION,
default => Environment::PREVIEW,
};
}
}