Completed
Push — master ( 0b2e6b...2c86a7 )
by Paul
49:42 queued 39:17
created

AppKernel   C

Complexity

Total Complexity 13

Size/Duplication

Total Lines 134
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 54

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 13
lcom 1
cbo 54
dl 0
loc 134
rs 5
c 2
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A registerContainerConfiguration() 0 4 1
A getCacheDir() 0 4 1
A getLogDir() 0 4 1
A registerBundles() 0 61 1
A shutdown() 0 14 3
B cleanupContainer() 0 21 6
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 8 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
use Symfony\Component\Config\Loader\LoaderInterface;
4
use Symfony\Component\HttpKernel\Kernel;
5
6
require_once __DIR__.'/autoload.php';
7
8
class AppKernel extends Kernel
9
{
10
    /**
11
     * @return array
12
     */
13
    public function registerBundles()
14
    {
15
        return [
16
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
17
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
18
            new Symfony\Bundle\TwigBundle\TwigBundle(),
19
            new Symfony\Bundle\MonologBundle\MonologBundle(),
20
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
21
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
22
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
23
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
24
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
25
26
            new AppVentus\AsseticInjectorBundle\AvAsseticInjectorBundle(),
27
            new AppVentus\AlertifyBundle\AvAlertifyBundle(),
28
            new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
29
            new FOS\UserBundle\FOSUserBundle(),
30
            new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
31
            new JMS\AopBundle\JMSAopBundle(),
32
            new JMS\TranslationBundle\JMSTranslationBundle(),
33
            new JMS\SerializerBundle\JMSSerializerBundle(),
34
            new JMS\DiExtraBundle\JMSDiExtraBundle($this),
35
            new Liip\ImagineBundle\LiipImagineBundle(),
36
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
37
            new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(),
38
            new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(),
39
            new Snc\RedisBundle\SncRedisBundle(),
40
            new Bazinga\Bundle\JsTranslationBundle\BazingaJsTranslationBundle(),
41
            new Knp\DoctrineBehaviors\Bundle\DoctrineBehaviorsBundle(),
42
            new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
43
            new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
44
45
            //Victoire bundles
46
            new Victoire\Bundle\AnalyticsBundle\VictoireAnalyticsBundle(),
47
            new Victoire\Bundle\CoreBundle\VictoireCoreBundle(),
48
            new Victoire\Bundle\BlogBundle\VictoireBlogBundle(),
49
            new Victoire\Bundle\BusinessEntityBundle\VictoireBusinessEntityBundle(),
50
            new Victoire\Bundle\BusinessPageBundle\VictoireBusinessPageBundle(),
51
            new Victoire\Bundle\FilterBundle\VictoireFilterBundle(),
52
            new Victoire\Bundle\I18nBundle\VictoireI18nBundle(),
53
            new Victoire\Bundle\FormBundle\VictoireFormBundle(),
54
            new Victoire\Bundle\PageBundle\VictoirePageBundle(),
55
            new Victoire\Bundle\QueryBundle\VictoireQueryBundle(),
56
            new Victoire\Bundle\MediaBundle\VictoireMediaBundle(),
57
            new Victoire\Bundle\SeoBundle\VictoireSeoBundle(),
58
            new Victoire\Bundle\SitemapBundle\VictoireSitemapBundle(),
59
            new Victoire\Bundle\TemplateBundle\VictoireTemplateBundle(),
60
            new Victoire\Bundle\TwigBundle\VictoireTwigBundle(),
61
            new Victoire\Bundle\UserBundle\VictoireUserBundle(),
62
            new Victoire\Bundle\ViewReferenceBundle\ViewReferenceBundle(),
63
            new Victoire\Bundle\WidgetBundle\VictoireWidgetBundle(),
64
            new Victoire\Bundle\WidgetMapBundle\VictoireWidgetMapBundle(),
65
            new Victoire\Bundle\CriteriaBundle\VictoireCriteriaBundle(),
66
            //Victoire test bundles
67
            new Victoire\Widget\ForceBundle\VictoireWidgetForceBundle(),
68
            new Victoire\Widget\LightSaberBundle\VictoireWidgetLightSaberBundle(),
69
            new Victoire\Widget\ButtonBundle\VictoireWidgetButtonBundle(),
70
            new Victoire\Widget\TextBundle\VictoireWidgetTextBundle(),
71
            new Acme\AppBundle\AcmeAppBundle(),
72
        ];
73
    }
74
75
    /**
76
     * @return null
77
     */
78
    public function registerContainerConfiguration(LoaderInterface $loader)
79
    {
80
        $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getCacheDir()
87
    {
88
        return sys_get_temp_dir().'/Victoire/cache';
89
    }
90
91
    /**
92
     * @return string
93
     */
94
    public function getLogDir()
95
    {
96
        return sys_get_temp_dir().'/Victoire/logs';
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    public function shutdown()
103
    {
104
        if ($this->environment === 'ci') {
105
            if (false === $this->booted) {
106
                return;
107
            }
108
109
            $container = $this->container;
110
            parent::shutdown();
111
            $this->cleanupContainer($container);
112
        } else {
113
            parent::shutdown();
114
        }
115
    }
116
117
    /**
118
     * Remove all container references from all loaded services.
119
     */
120
    protected function cleanupContainer($container)
121
    {
122
        $object = new \ReflectionObject($container);
123
        $property = $object->getProperty('services');
124
        $property->setAccessible(true);
125
        $services = $property->getValue($container) ?: [];
126
        foreach ($services as $id => $service) {
127
            if ('kernel' === $id) {
128
                continue;
129
            }
130
            $serviceObject = new \ReflectionObject($service);
131
            foreach ($serviceObject->getProperties() as $prop) {
132
                $prop->setAccessible(true);
133
                if ($prop->isStatic()) {
134
                    continue;
135
                }
136
                $prop->setValue($service, null);
137
            }
138
        }
139
        $property->setValue($container, null);
140
    }
141
}
142