Passed
Push — 1.11.x ( 8d76d0...8c27c9 )
by Yannick
11:37
created

AppKernel   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 217
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
eloc 75
c 1
b 0
f 0
dl 0
loc 217
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __serialize() 0 3 1
A getRealRootDir() 0 3 1
A setApi() 0 3 1
A getAppDir() 0 3 1
A __unserialize() 0 2 1
B registerBundles() 0 127 2
A getDataDir() 0 3 1
A getRootDir() 0 8 2
A registerContainerConfiguration() 0 3 1
A getConfigDir() 0 3 1
A getConfigurationFile() 0 3 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
use Symfony\Component\HttpKernel\Kernel;
5
use Symfony\Component\Config\Loader\LoaderInterface;
6
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
7
8
/**
9
 * Class AppKernel
10
 */
11
class AppKernel extends Kernel
12
{
13
    protected $rootDir;
14
15
    /*
16
    Update for PHP 8 support DamienR : AppKernel implements the Serializable interface, which is deprecated. 
17
    Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) 
18
    */
19
    public function __serialize(): array
20
    {
21
        return [];
22
    }
23
24
    public function __unserialize(array $data): void
25
    {
26
        // Implement the logic to unserialize the object
27
    }
28
    
29
    public function registerBundles()
30
    {
31
        $bundles = array(
32
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
33
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
34
            new Symfony\Bundle\TwigBundle\TwigBundle(),
35
            new Symfony\Bundle\MonologBundle\MonologBundle(),
36
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
37
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
38
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
39
40
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
41
            new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
42
            //new Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
43
            new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
44
45
            new FOS\RestBundle\FOSRestBundle(),
46
            new JMS\SerializerBundle\JMSSerializerBundle($this),
47
48
            // KNP HELPER BUNDLES
49
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
50
            new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
51
            // Data grid
52
            //new APY\DataGridBundle\APYDataGridBundle(),
53
            new Chamilo\FaqBundle\ChamiloFaqBundle(),
54
            new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
55
            new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
56
57
            // Sonata
58
            new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
59
            new Sonata\CoreBundle\SonataCoreBundle(),
60
            new Sonata\IntlBundle\SonataIntlBundle(),
61
            new Sonata\FormatterBundle\SonataFormatterBundle(),
62
            new Sonata\CacheBundle\SonataCacheBundle(),
63
            new Sonata\BlockBundle\SonataBlockBundle(),
64
            new Sonata\SeoBundle\SonataSeoBundle(),
65
            new Sonata\ClassificationBundle\SonataClassificationBundle(),
66
            new Sonata\NotificationBundle\SonataNotificationBundle(),
67
            new Sonata\DatagridBundle\SonataDatagridBundle(),
68
            new Sonata\MediaBundle\SonataMediaBundle(),
69
            new Sonata\PageBundle\SonataPageBundle(),
70
            new Theodo\Evolution\Bundle\SessionBundle\TheodoEvolutionSessionBundle(),
71
72
            new Spy\TimelineBundle\SpyTimelineBundle(),
73
            new Sonata\TimelineBundle\SonataTimelineBundle(),
74
75
            //new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
76
77
            new Sonata\AdminBundle\SonataAdminBundle(),
78
            new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
79
80
81
            // CMF Integration
82
            new Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
83
            //new Symfony\Cmf\Bundle\SearchBundle\CmfSearchBundle(),
84
            //new Symfony\Cmf\Bundle\BlogBundle\CmfBlogBundle(),
85
            //new Sonata\DoctrinePHPCRAdminBundle\SonataDoctrinePHPCRAdminBundle(),
86
87
            // Oauth
88
            //new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
89
90
            //new Gregwar\CaptchaBundle\GregwarCaptchaBundle(),
91
            new Mopa\Bundle\BootstrapBundle\MopaBootstrapBundle(),
92
            //new Liip\ThemeBundle\LiipThemeBundle(),
93
            new Ivory\CKEditorBundle\IvoryCKEditorBundle(),
94
            new FM\ElfinderBundle\FMElfinderBundle(),
95
            new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
96
            new Knp\DoctrineBehaviors\Bundle\DoctrineBehaviorsBundle(),
97
98
            // User
99
            new FOS\UserBundle\FOSUserBundle(),
100
            new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'),
101
            new Chamilo\UserBundle\ChamiloUserBundle(),
102
            /*
103
            // Sylius
104
            /*new Sylius\Bundle\SettingsBundle\SyliusSettingsBundle(),
105
            //new Sylius\Bundle\AttributeBundle\SyliusAttributeBundle(),
106
            new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
107
            new Sylius\Bundle\FlowBundle\SyliusFlowBundle(),
108
            new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
109
            new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),*/
110
111
            // Chamilo
112
            //new Chamilo\InstallerBundle\ChamiloInstallerBundle(),
113
            new Chamilo\CoreBundle\ChamiloCoreBundle(),
114
            new Chamilo\CourseBundle\ChamiloCourseBundle(),
115
            // new Chamilo\SettingsBundle\ChamiloSettingsBundle(),
116
            new Chamilo\ThemeBundle\ChamiloThemeBundle(),
117
            //new Chamilo\NotificationBundle\ChamiloNotificationBundle(),
118
            new Chamilo\AdminBundle\ChamiloAdminBundle(),
119
            new Chamilo\TimelineBundle\ChamiloTimelineBundle(),
120
            new \Chamilo\ContactBundle\ChamiloContactBundle(),
121
122
            // Based in Sonata
123
            new Chamilo\ClassificationBundle\ChamiloClassificationBundle(),
124
            new Chamilo\MediaBundle\ChamiloMediaBundle(),
125
            new Chamilo\PageBundle\ChamiloPageBundle(),
126
            /*
127
            // Chamilo course tool
128
            //new Chamilo\NotebookBundle\ChamiloNotebookBundle(),
129
130
            // Data
131
            //new Oneup\FlysystemBundle\OneupFlysystemBundle(), */
132
133
            // Extra
134
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
135
136
            /*
137
            //new JMS\TranslationBundle\JMSTranslationBundle(),
138
            //new JMS\DiExtraBundle\JMSDiExtraBundle($this),
139
            //new JMS\AopBundle\JMSAopBundle(),
140
            /*new Bazinga\Bundle\FakerBundle\BazingaFakerBundle(),
141
            //new Chamilo\CmsBundle\ChamiloCmsBundle(),
142
             */
143
            new Lunetics\LocaleBundle\LuneticsLocaleBundle()
144
        );
145
146
        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
147
            //$bundles[] = new Jjanvier\Bundle\CrowdinBundle\JjanvierCrowdinBundle();
148
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
149
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
150
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
151
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
152
            //$bundles[] = new Sp\BowerBundle\SpBowerBundle();
153
        }
154
155
        return $bundles;
156
    }
157
158
    /**
159
     * @param LoaderInterface $loader
160
     */
161
    public function registerContainerConfiguration(LoaderInterface $loader)
162
    {
163
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
164
    }
165
166
167
    /**
168
     * @return string
169
     */
170
    public function getRootDir()
171
    {
172
        if (null === $this->rootDir) {
173
            $r = new \ReflectionObject($this);
174
            $this->rootDir = str_replace('\\', '/', dirname($r->getFileName()));
175
        }
176
177
        return $this->rootDir;
178
    }
179
180
    /**
181
     * Returns the real root path
182
     * @return string
183
     */
184
    public function getRealRootDir()
185
    {
186
        return realpath($this->getRootDir().'/../').'/';
187
    }
188
189
    /**
190
     * Returns the data path
191
     * @return string
192
     */
193
    public function getDataDir()
194
    {
195
        return $this->getRealRootDir().'data/';
196
    }
197
198
    /**
199
     * @return string
200
     */
201
    public function getAppDir()
202
    {
203
        return $this->getRealRootDir().'app/';
204
    }
205
206
    /**
207
     * @return string
208
     */
209
    public function getConfigDir()
210
    {
211
        return $this->getRealRootDir().'app/config/';
212
    }
213
214
    /**
215
     * @return string
216
     */
217
    public function getConfigurationFile()
218
    {
219
        return $this->getRealRootDir().'app/config/configuration.php';
220
    }
221
222
    /**
223
     * @param array $configuration
224
     */
225
    public function setApi(array $configuration)
226
    {
227
        new ChamiloApi($configuration);
228
    }
229
}
230
231