DoctrinevizBundleExtension::prepend()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
/*
4
 * This file is part of the doctrineviz package
5
 *
6
 * Copyright (c) 2017 Pierre Hennequart
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Pierre Hennequart <[email protected]>
14
 */
15
16
declare(strict_types=1);
17
18
namespace Janalis\Doctrineviz\DependencyInjection;
19
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
22
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
23
24
/**
25
 * This is the class that loads and manages your bundle configuration.
26
 *
27
 * @see http://symfony.com/doc/current/cookbook/bundles/extension.html
28
 */
29
class DoctrinevizBundleExtension extends Extension implements PrependExtensionInterface
30
{
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function prepend(ContainerBuilder $container)
35
    {
36
        $requiredBundles = [
37
            'DoctrineBundle',
38
        ];
39
        // get all bundles
40
        $bundles = $container->getParameter('kernel.bundles');
41
        // determine if required bundles are registered
42
        foreach ($requiredBundles as $requiredBundle) {
43
            if (!isset($bundles[$requiredBundle])) {
44
                throw new \RuntimeException($requiredBundle.' must be registered in your application.');
45
            }
46
        }
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function load(array $configs, ContainerBuilder $container)
53
    {
54
        $configuration = new Configuration($this->getAlias());
55
        $this->processConfiguration($configuration, $configs);
56
    }
57
}
58