Completed
Push — master ( dda990...bade66 )
by Nathan
07:38
created

EasyHtmlElementExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 17 1
1
<?php
2
3
namespace NatePage\EasyHtmlElement\Bridge\Symfony\DependencyInjection;
4
5
use NatePage\EasyHtmlElement\HtmlElement;
6
use NatePage\EasyHtmlElement\Bridge\Twig\EasyHtmlElementExtension as TwigExtension;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Definition;
9
use Symfony\Component\DependencyInjection\Extension\Extension;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
class EasyHtmlElementExtension extends Extension
13
{
14
    const SERVICE_NAME = 'easy_html_element';
15
    const TWIG_EXTENSION_NAME = 'easy_html_element.twig_extension';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function load(array $configs, ContainerBuilder $container)
21
    {
22
        $config = new Configuration();
23
        $config = $this->processConfiguration($config, $configs);
24
25
        $map = $config['map'];
26
27
        $container->setDefinition(self::SERVICE_NAME, new Definition(HtmlElement::class, array($map)));
28
29
        $container
30
            ->setDefinition(self::TWIG_EXTENSION_NAME, new Definition(
31
                TwigExtension::class, array(new Reference(self::SERVICE_NAME))
32
            ))
33
            ->addTag('twig.extension')
34
            ->setPublic(false)
35
        ;
36
    }
37
}
38