1 | <?php |
||
17 | abstract class Loader extends Object |
||
18 | { |
||
19 | /** |
||
20 | * @var string|string[]|null a tier name or an array of tier names to match a tier name specified in [[Config]]. |
||
21 | * |
||
22 | * If there're an array it will match *any of* specified values. |
||
23 | * You can also use an exclamation mark (`!`) before a name to use a `not` match. Example: |
||
24 | * |
||
25 | * ```php |
||
26 | * [ |
||
27 | * 'tier1', |
||
28 | * '!tier2', |
||
29 | * ] |
||
30 | * ``` |
||
31 | * |
||
32 | * It matches if the tier name is `tier1` *or* **not** `tier2`. |
||
33 | */ |
||
34 | public $tier; |
||
35 | |||
36 | /** |
||
37 | * @var string|string[]|null an environment name or an array of environment names to match an environment name specified in [[Config]]. |
||
38 | * |
||
39 | * If there're an array it will match *any of* specified values. |
||
40 | * You can also use an exclamation mark (`!`) before a name to use a `not` match. Example: |
||
41 | * |
||
42 | * ```php |
||
43 | * [ |
||
44 | * 'env1', |
||
45 | * '!env2', |
||
46 | * ] |
||
47 | * ``` |
||
48 | * |
||
49 | * It matches if the environment name is `env1` *or* **not** `env2`. |
||
50 | */ |
||
51 | public $env; |
||
52 | |||
53 | /** |
||
54 | * @var string full path to a directory where [[Config]] will store its cached configs. |
||
55 | */ |
||
56 | public $path; |
||
57 | |||
58 | /** |
||
59 | * @var bool whether the file is required. |
||
60 | */ |
||
61 | public $required = true; |
||
62 | |||
63 | /** |
||
64 | * @var bool whether to look for a local config in addition to a main one. |
||
65 | * |
||
66 | * For example, if [[$enableLocal]] is `true` and a main config file name is `NAME.EXT`, |
||
67 | * [[Config]] will also look for the `NAME-local.EXT` file. |
||
68 | */ |
||
69 | public $enableLocal = true; |
||
70 | |||
71 | /** |
||
72 | * @var Config [[Config]] instance. |
||
73 | */ |
||
74 | protected $config; |
||
75 | |||
76 | /** |
||
77 | * @var Storage internal config object instance. |
||
78 | */ |
||
79 | protected $storage; |
||
80 | |||
81 | /** |
||
82 | * Creates a new Loader object. |
||
83 | * @param Config $configObject current [[Config]] instance. |
||
84 | * @param Storage $storage internal config object instance. |
||
85 | * @param array $config name-value pairs that will be used to initialize the object properties. |
||
86 | */ |
||
87 | 62 | public function __construct(Config $configObject, Storage $storage, $config = []) |
|
93 | |||
94 | /** |
||
95 | * Compiles resolved files into the internal config object. |
||
96 | */ |
||
97 | abstract public function compile(); |
||
98 | |||
99 | /** |
||
100 | * Loads resolved files into the internal config object. |
||
101 | */ |
||
102 | abstract public function load(); |
||
103 | |||
104 | /** |
||
105 | * Resolves the current configuration into config file pathes. |
||
106 | * @return string[] config file pathes. |
||
107 | * @throws ConfigNotFoundException |
||
108 | */ |
||
109 | 49 | public function resolveFiles() |
|
145 | |||
146 | /** |
||
147 | * Returns a file path with a "-local" suffix. |
||
148 | * @param string $path the file path. |
||
149 | * @return string file path with a "-local" suffix. |
||
150 | */ |
||
151 | 44 | protected function makeLocalPath($path) |
|
163 | |||
164 | /** |
||
165 | * Returns whether the configuration allows to load this config. |
||
166 | * @return bool whether the configuration allows to load this config. |
||
167 | */ |
||
168 | 49 | protected function isAllowed() |
|
180 | |||
181 | /** |
||
182 | * Returns whether the value is in the list of allowed values. |
||
183 | * @param mixed $value the value to be tested. |
||
184 | * @param mixed $allowedValues the list of allowed values. |
||
185 | * @return bool whether the value is in the list of allowed values. |
||
186 | */ |
||
187 | 49 | protected function isValueAllowed($value, $allowedValues) |
|
206 | } |
||
207 |