forked from lolautruche/EzCoreExtraBundle
/
EzCoreExtraExtension.php
52 lines (44 loc) · 2.16 KB
/
EzCoreExtraExtension.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
* This file is part of the EzCoreExtraBundle package.
*
* (c) Jérôme Vieilledent <jerome@vieilledent.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Lolautruche\EzCoreExtraBundle\DependencyInjection;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface;
use Lolautruche\EzCoreExtraBundle\View\ViewParameterProviderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
class EzCoreExtraExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('default_settings.yml');
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$processor = new ConfigurationProcessor($container, 'ez_core_extra');
$this->configureDesigns($config, $processor, $container);
$processor->mapConfig(
$config,
function (array $scopeSettings, $currentScope, ContextualizerInterface $contextualizer) {
$contextualizer->setContextualParameter('security.authentication_email.enabled', $currentScope, $scopeSettings['enable_email_authentication']);
}
);
if (method_exists($container, 'registerForAutoconfiguration')) {
$container->registerForAutoconfiguration(ViewParameterProviderInterface::class)
->addTag('ez_core_extra.view_parameter_provider');
}
}
private function configureDesigns(array $config, ConfigurationProcessor $processor, ContainerBuilder $container)
{
$processor->mapConfigArray('twig_globals', $config);
}
}