1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Marek\SiteAccessAwareDateFormatBundle\DependencyInjection; |
6
|
|
|
|
7
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor; |
8
|
|
|
use Symfony\Component\Config\FileLocator; |
9
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
10
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
11
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This is the class that loads and manages your bundle configuration. |
15
|
|
|
* |
16
|
|
|
* @see http://symfony.com/doc/current/cookbook/bundles/extension.html |
17
|
|
|
*/ |
18
|
|
|
class MarekSiteAccessAwareDateFormatExtension extends Extension |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
*/ |
23
|
|
|
public function load(array $configs, ContainerBuilder $container) |
24
|
|
|
{ |
25
|
|
|
$configuration = new Configuration(); |
26
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
27
|
|
|
|
28
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
29
|
|
|
$loader->load('services.yml'); |
30
|
|
|
|
31
|
|
|
$processor = new ConfigurationProcessor($container, Configuration::TREE_ROOT); |
32
|
|
|
$configArrays = ['defaults', 'formats']; |
33
|
|
|
|
34
|
|
|
$scopes = array_merge(['default'], $container->getParameter('ezpublish.siteaccess.list')); |
35
|
|
|
foreach ($configArrays as $configArray) { |
36
|
|
|
$processor->mapConfigArray($configArray, $config); |
37
|
|
|
foreach ($scopes as $scope) { |
38
|
|
|
$paramName = Configuration::TREE_ROOT . '.' . $scope . '.' . $configArray; |
39
|
|
|
|
40
|
|
|
if (!$container->hasParameter($paramName)) { |
41
|
|
|
continue; |
42
|
|
|
} |
43
|
|
|
$scopeConfig = $container->getParameter($paramName); |
44
|
|
|
foreach ((array) $scopeConfig as $key => $value) { |
45
|
|
|
$container->setParameter($paramName . '.' . $key, $value); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|