1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Netgen\Bundle\OpenWeatherMapBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor; |
6
|
|
|
use Symfony\Component\Config\FileLocator; |
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
8
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
9
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
10
|
|
|
|
11
|
|
|
class NetgenOpenWeatherMapExtension extends Extension |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* {@inheritdoc} |
15
|
|
|
*/ |
16
|
|
|
public function load(array $configs, ContainerBuilder $container) |
17
|
|
|
{ |
18
|
|
|
$configuration = new Configuration(); |
19
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
20
|
|
|
|
21
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
22
|
|
|
$loader->load('services.yml'); |
23
|
|
|
|
24
|
|
|
$processor = new ConfigurationProcessor($container, 'netgen_open_weather_map'); |
25
|
|
|
$configArrays = array('api_settings', 'cache_settings'); |
26
|
|
|
|
27
|
|
|
$scopes = array_merge(array('default'), $container->getParameter('ezpublish.siteaccess.list')); |
28
|
|
|
|
29
|
|
|
foreach ($configArrays as $configArray) { |
30
|
|
|
$processor->mapConfigArray($configArray, $config); |
31
|
|
|
|
32
|
|
|
foreach ($scopes as $scope) { |
33
|
|
|
$scopeConfig = $container->getParameter('netgen_open_weather_map.' . $scope . '.' . $configArray); |
34
|
|
|
foreach ($scopeConfig as $key => $value) { |
35
|
|
|
$container->setParameter( |
36
|
|
|
'netgen_open_weather_map.' . $scope . '.' . $configArray . '.' . $key, |
37
|
|
|
$value |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|