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
|
|
|
} |