1 | <?php |
||
18 | class SiteAliasWithConfig implements SiteAliasInterface, ConfigRuntimeInterface |
||
19 | { |
||
20 | use SiteAliasTrait; |
||
21 | |||
22 | protected $runtimeConfig; |
||
23 | protected $siteAlias; |
||
24 | protected $defaultConfig; |
||
25 | |||
26 | public function __construct(SiteAliasInterface $siteAlias, ConfigInterface $defaultConfig, ConfigInterface $runtimeConfig) |
||
32 | |||
33 | /** |
||
34 | * combine the provided site alias with configuration. |
||
35 | * |
||
36 | * @return SiteAlias read-only site alias combined with the runtime |
||
37 | * config (overrides the site alias values) and the default config. |
||
38 | */ |
||
39 | public static function create(SiteAliasInterface $siteAlias, ConfigInterface $defaultConfig, ConfigInterface $runtimeConfig = null) |
||
45 | |||
46 | /** |
||
47 | * Determine what object to use for the runtime config. If a specific |
||
48 | * runtime config is given, use that. Otherwise, pull it from the default |
||
49 | * configuration if available. |
||
50 | */ |
||
51 | protected static function determineCorrectRuntimeConfig(ConfigInterface $defaultConfig, ConfigInterface $runtimeConfig) |
||
63 | |||
64 | /** |
||
65 | * @inheritdoc |
||
66 | */ |
||
67 | public function runtimeConfig() |
||
71 | |||
72 | /** |
||
73 | * @inheritdoc |
||
74 | */ |
||
75 | public function name() |
||
79 | |||
80 | /** |
||
81 | * @inheritdoc |
||
82 | */ |
||
83 | public function has($key) |
||
90 | |||
91 | /** |
||
92 | * @inheritdoc |
||
93 | */ |
||
94 | public function get($key, $defaultFallback = null) |
||
108 | |||
109 | /** |
||
110 | * @inheritdoc |
||
111 | */ |
||
112 | public function set($key, $value) |
||
116 | |||
117 | /** |
||
118 | * @inheritdoc |
||
119 | */ |
||
120 | public function import($data) |
||
124 | |||
125 | /** |
||
126 | * @inheritdoc |
||
127 | */ |
||
128 | public function replace($data) |
||
132 | |||
133 | /** |
||
134 | * @inheritdoc |
||
135 | */ |
||
136 | public function combine($data) |
||
140 | |||
141 | /** |
||
142 | * Export all configuration as a nested array. |
||
143 | */ |
||
144 | public function export() |
||
148 | |||
149 | /** |
||
150 | * @inheritdoc |
||
151 | */ |
||
152 | public function hasDefault($key) |
||
156 | |||
157 | /** |
||
158 | * @inheritdoc |
||
159 | */ |
||
160 | public function getDefault($key, $defaultFallback = null) |
||
164 | |||
165 | /** |
||
166 | * @inheritdoc |
||
167 | */ |
||
168 | public function setDefault($key, $value) |
||
172 | |||
173 | /** |
||
174 | * @inheritdoc |
||
175 | */ |
||
176 | public function exportConfig() |
||
180 | |||
181 | protected function changesProhibited() |
||
185 | } |
||
186 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: