Conditions | 5 |
Paths | 4 |
Total Lines | 26 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public function loadConfiguration() |
||
23 | { |
||
24 | $builder = $this->getContainerBuilder(); |
||
25 | $config = $this->getConfig($this->defaults); |
||
26 | |||
27 | $environment = $builder->addDefinition($this->prefix('environment')) |
||
28 | ->setClass(Environment::class); |
||
29 | |||
30 | if (empty($config['profile'])) |
||
31 | throw new ConfigurationException("You must define some profile combination in your configuration."); |
||
32 | |||
33 | $requiredProfileParams = ['country', 'language', 'currency']; |
||
34 | foreach ($config['profile'] as $profileName => $profile) |
||
35 | { |
||
36 | if (!empty(array_diff($requiredProfileParams, array_keys($profile)))) |
||
37 | throw new ConfigurationException("Problem with \"{$profileName}\" profile configuration. There are missing some of the required parameters (country, language, currency)."); |
||
38 | |||
39 | $environment->addSetup('addProfile', [ |
||
40 | $profileName, |
||
41 | (array) $profile['country'], |
||
42 | (array) $profile['language'], |
||
43 | (array) $profile['currency'], |
||
44 | array_key_exists('domain', $profile) ? (array) $profile['domain'] : [] |
||
45 | ]); |
||
46 | } |
||
47 | } |
||
48 | |||
50 | } |