Completed
Push — master ( 5a9475...710488 )
by Beñat
02:26
created

ClassMapTemplateFactoryPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 21
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 4
1
<?php
2
3
/*
4
 * This file is part of the CMS Kernel package.
5
 *
6
 * Copyright (c) 2016-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LIN3S\CMSKernel\Infrastructure\Symfony\Bundle\DependencyInjection\Compiler;
13
14
use LIN3S\CMSKernel\Infrastructure\Domain\Model\Template\ClassMapTemplateFactory;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Definition;
18
19
/**
20
 * @author Beñat Espiña <[email protected]>
21
 */
22
class ClassMapTemplateFactoryPass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function process(ContainerBuilder $container)
28
    {
29
        $config = $container->getParameter('lin3s_cms_kernel.config');
30
31
        if (!isset($config['templates']) || !isset($config['templates']['class_map'])) {
32
            return;
33
        }
34
35
        foreach ($config['templates']['class_map'] as $entity => $templates) {
36
            $container->setDefinition(
37
                'lin3s_cms_kernel.' . $entity . '.template_factory',
38
                (new Definition(ClassMapTemplateFactory::class))
39
            )->addArgument($templates);
40
        }
41
    }
42
}
43