MsalsasGdprConsentBannerExtension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 11
ccs 10
cts 10
cp 1
crap 1
rs 9.9666
1
<?php
2
3
namespace Msalsas\GdprConsentBannerBundle\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
8
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
10
11
class MsalsasGdprConsentBannerExtension extends Extension implements PrependExtensionInterface
12
{
13 9
    public function load(array $configs, ContainerBuilder $container)
14
    {
15 9
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
16 9
        $loader->load('services.xml');
17 9
        $config = $this->processConfiguration(new Configuration(), $configs);
18 7
         $container->setParameter('msalsas_gdpr_consent_banner.has_translations', $config['has_translations']);
19 7
         $container->setParameter('msalsas_gdpr_consent_banner.css', $config['css']);
20 7
         $container->setParameter('msalsas_gdpr_consent_banner.fade_time', $config['fade_time']);
21 7
         $container->setParameter('msalsas_gdpr_consent_banner.text_message', $config['text_message']);
22 7
         $container->setParameter('msalsas_gdpr_consent_banner.accept_message', $config['accept_message']);
23 7
         $container->setParameter('msalsas_gdpr_consent_banner.time_to_expire', $config['time_to_expire']);
24 7
    }
25
26 1
    public function prepend(ContainerBuilder $container)
27
    {
28 1
        $configs = $container->getExtensionConfig($this->getAlias());
29 1
        $config = $this->processConfiguration(new Configuration(), $configs);
30
31 1
        $twigConfig = [];
32 1
        $twigConfig['globals']['msalsas_gdpr_consent_banner']['has_translations'] = $config["has_translations"];
33 1
        $twigConfig['globals']['msalsas_gdpr_consent_banner']['css'] = $config["css"];
34 1
        $twigConfig['globals']['msalsas_gdpr_consent_banner']['fade_time'] = $config["fade_time"];
35 1
        $twigConfig['globals']['msalsas_gdpr_consent_banner']['text_message'] = $config["text_message"];
36 1
        $twigConfig['globals']['msalsas_gdpr_consent_banner']['accept_message'] = $config["accept_message"];
37 1
        $twigConfig['paths'][__DIR__.'/../Resources/views'] = "msalsas_gdpr_consent_banner";
38 1
        $twigConfig['paths'][__DIR__.'/../Resources/public'] = "msalsas_gdpr_consent_banner.public";
39 1
        $container->prependExtensionConfig('twig', $twigConfig);
40 1
    }
41
42 1
    public function getAlias()
43
    {
44 1
        return 'msalsas_gdpr_consent_banner';
45
    }
46
}