Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/env/PhabricatorScopedEnv.php
12241 views
1
<?php
2
3
/**
4
* Scope guard to hold a temporary environment. See @{class:PhabricatorEnv} for
5
* instructions on use.
6
*
7
* @task internal Internals
8
* @task override Overriding Environment Configuration
9
*/
10
final class PhabricatorScopedEnv extends Phobject {
11
12
private $key;
13
private $isPopped = false;
14
15
/* -( Overriding Environment Configuration )------------------------------- */
16
17
/**
18
* Override a configuration key in this scope, setting it to a new value.
19
*
20
* @param string Key to override.
21
* @param wild New value.
22
* @return this
23
*
24
* @task override
25
*/
26
public function overrideEnvConfig($key, $value) {
27
PhabricatorEnv::overrideTestEnvConfig(
28
$this->key,
29
$key,
30
$value);
31
return $this;
32
}
33
34
35
/* -( Internals )---------------------------------------------------------- */
36
37
38
/**
39
* @task internal
40
*/
41
public function __construct($stack_key) {
42
$this->key = $stack_key;
43
}
44
45
46
/**
47
* Release the scoped environment.
48
*
49
* @return void
50
* @task internal
51
*/
52
public function __destruct() {
53
if (!$this->isPopped) {
54
PhabricatorEnv::popTestEnvironment($this->key);
55
$this->isPopped = true;
56
}
57
}
58
59
}
60
61