Completed
Branch master (01610a)
by Arnaud
02:58
created

LAGAdminBundle   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 6
c 3
b 1
f 1
lcom 1
cbo 4
dl 0
loc 40
ccs 0
cts 24
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 8 1
B getContainerExtension() 0 20 5
1
<?php
2
3
namespace LAG\AdminBundle;
4
5
use LAG\AdminBundle\DependencyInjection\DataProviderCompilerPass;
6
use LAG\AdminBundle\DependencyInjection\FieldCompilerPass;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
9
use Symfony\Component\HttpKernel\Bundle\Bundle;
10
11
class LAGAdminBundle extends Bundle
12
{
13
    /**
14
     * Add the field and the data provider compiler pass
15
     *
16
     * @param ContainerBuilder $container
17
     */
18
    public function build(ContainerBuilder $container)
19
    {
20
        parent::build($container);
21
22
        // register field compiler pass
23
        $container->addCompilerPass(new FieldCompilerPass());
24
        $container->addCompilerPass(new DataProviderCompilerPass());
25
    }
26
27
    /**
28
     * @return bool|ExtensionInterface
29
     */
30
    public function getContainerExtension()
31
    {
32
        if (null === $this->extension) {
33
            $class = $this->getContainerExtensionClass();
34
35
            if (class_exists($class)) {
36
                $extension = new $class();
37
38
                if (!$extension instanceof ExtensionInterface) {
39
                    throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', $class));
40
                }
41
                $this->extension = $extension;
42
            } else {
43
                $this->extension = false;
44
            }
45
        }
46
        if ($this->extension) {
47
            return $this->extension;
48
        }
49
    }
50
}
51