Completed
Push — master ( f98a23...5ff861 )
by Kamil
15s
created

Kernel   C

Complexity

Total Complexity 14

Size/Duplication

Total Lines 164
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 80

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 14
lcom 1
cbo 80
dl 0
loc 164
rs 5
c 1
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
B registerBundles() 0 93 2
A getContainerBaseClass() 0 8 2
A registerContainerConfiguration() 0 10 1
A getCacheDir() 0 8 2
A getLogDir() 0 8 2
A isVagrantEnvironment() 0 4 3
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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 Sylius\Bundle\CoreBundle\Application;
13
14
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
15
use Symfony\Component\Config\Loader\LoaderInterface;
16
use Symfony\Component\HttpKernel\Kernel as HttpKernel;
17
18
/**
19
 * @author Paweł Jędrzejewski <[email protected]>
20
 * @author Gonzalo Vilaseca <[email protected]>
21
 */
22
class Kernel extends HttpKernel
23
{
24
    const VERSION = '0.19.0-dev';
25
    const VERSION_ID = '00190';
26
    const MAJOR_VERSION = '0';
27
    const MINOR_VERSION = '19';
28
    const RELEASE_VERSION = '0';
29
    const EXTRA_VERSION = 'DEV';
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function registerBundles()
35
    {
36
        $bundles = [
37
            new \Sylius\Bundle\InstallerBundle\SyliusInstallerBundle(),
38
            new \Sylius\Bundle\OrderBundle\SyliusOrderBundle(),
39
            new \Sylius\Bundle\MoneyBundle\SyliusMoneyBundle(),
40
            new \Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle(),
41
            new \Sylius\Bundle\ContactBundle\SyliusContactBundle(),
42
            new \Sylius\Bundle\LocaleBundle\SyliusLocaleBundle(),
43
            new \Sylius\Bundle\SettingsBundle\SyliusSettingsBundle(),
44
            new \Sylius\Bundle\CartBundle\SyliusCartBundle(),
45
            new \Sylius\Bundle\ProductBundle\SyliusProductBundle(),
46
            new \Sylius\Bundle\ArchetypeBundle\SyliusArchetypeBundle(),
47
            new \Sylius\Bundle\ChannelBundle\SyliusChannelBundle(),
48
            new \Sylius\Bundle\VariationBundle\SyliusVariationBundle(),
49
            new \Sylius\Bundle\AttributeBundle\SyliusAttributeBundle(),
50
            new \Sylius\Bundle\TaxationBundle\SyliusTaxationBundle(),
51
            new \Sylius\Bundle\ShippingBundle\SyliusShippingBundle(),
52
            new \Sylius\Bundle\PaymentBundle\SyliusPaymentBundle(),
53
            new \Sylius\Bundle\MailerBundle\SyliusMailerBundle(),
54
            new \Sylius\Bundle\ReportBundle\SyliusReportBundle(),
55
            new \Sylius\Bundle\PromotionBundle\SyliusPromotionBundle(),
56
            new \Sylius\Bundle\AddressingBundle\SyliusAddressingBundle(),
57
            new \Sylius\Bundle\InventoryBundle\SyliusInventoryBundle(),
58
            new \Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle(),
59
            new \Sylius\Bundle\FlowBundle\SyliusFlowBundle(),
60
            new \Sylius\Bundle\PricingBundle\SyliusPricingBundle(),
61
            new \Sylius\Bundle\SequenceBundle\SyliusSequenceBundle(),
62
            new \Sylius\Bundle\ContentBundle\SyliusContentBundle(),
63
            new \Sylius\Bundle\SearchBundle\SyliusSearchBundle(),
64
            new \Sylius\Bundle\RbacBundle\SyliusRbacBundle(),
65
            new \Sylius\Bundle\UserBundle\SyliusUserBundle(),
66
            new \Sylius\Bundle\UiBundle\SyliusUiBundle(),
67
            new \Sylius\Bundle\AdminBundle\SyliusAdminBundle(),
68
            new \Sylius\Bundle\ShopBundle\SyliusShopBundle(),
69
            new \Sylius\Bundle\MetadataBundle\SyliusMetadataBundle(),
70
            new \Sylius\Bundle\AssociationBundle\SyliusAssociationBundle(),
71
            new \Sylius\Bundle\ReviewBundle\SyliusReviewBundle(),
72
            new \Sylius\Bundle\CoreBundle\SyliusCoreBundle(),
73
            new \Sylius\Bundle\WebBundle\SyliusWebBundle(),
74
            new \Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
75
            new \Sylius\Bundle\GridBundle\SyliusGridBundle(),
76
            new \winzou\Bundle\StateMachineBundle\winzouStateMachineBundle(),
77
            new \Sylius\Bundle\ApiBundle\SyliusApiBundle(),
78
79
            new \Sonata\BlockBundle\SonataBlockBundle(),
80
            new \Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(),
81
            new \Symfony\Cmf\Bundle\BlockBundle\CmfBlockBundle(),
82
            new \Symfony\Cmf\Bundle\ContentBundle\CmfContentBundle(),
83
            new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
84
            new \Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle(),
85
            new \Symfony\Cmf\Bundle\CreateBundle\CmfCreateBundle(),
86
            new \Symfony\Cmf\Bundle\MediaBundle\CmfMediaBundle(),
87
88
            new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
89
            new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
90
            new \Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
91
            new \Symfony\Bundle\AsseticBundle\AsseticBundle(),
92
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
93
            new \Symfony\Bundle\MonologBundle\MonologBundle(),
94
            new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
95
            new \Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
96
            new \Symfony\Bundle\TwigBundle\TwigBundle(),
97
98
            new \Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),
99
            new \FOS\OAuthServerBundle\FOSOAuthServerBundle(),
100
            new \FOS\RestBundle\FOSRestBundle(),
101
102
            new \FOS\ElasticaBundle\FOSElasticaBundle(),
103
            new \Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
104
            new \Knp\Bundle\MenuBundle\KnpMenuBundle(),
105
            new \Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
106
            new \Liip\ImagineBundle\LiipImagineBundle(),
107
            new \Payum\Bundle\PayumBundle\PayumBundle(),
108
            new \JMS\SerializerBundle\JMSSerializerBundle(),
109
            new \JMS\TranslationBundle\JMSTranslationBundle(),
110
            new \Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
111
            new \WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
112
113
            new \Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
114
            new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
115
            new \Sylius\Bundle\FixturesBundle\SyliusFixturesBundle(),
116
            new \Sylius\Bundle\PayumBundle\SyliusPayumBundle(), // must be added after PayumBundle.
117
            new \Sylius\Bundle\ThemeBundle\SyliusThemeBundle(), // must be added after FrameworkBundle
118
        ];
119
120
        if (in_array($this->environment, ['dev', 'test'], true)) {
121
            $bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle();
122
            $bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
123
        }
124
125
        return $bundles;
126
    }
127
128
    /**
129
     * {@inheritdoc}
130
     */
131
    protected function getContainerBaseClass()
132
    {
133
        if ('test' === $this->environment || 'test_cached' === $this->environment) {
134
            return MockerContainer::class;
135
        }
136
137
        return parent::getContainerBaseClass();
138
    }
139
140
    /**
141
     * {@inheritdoc}
142
     */
143
    public function registerContainerConfiguration(LoaderInterface $loader)
144
    {
145
        $rootDir = $this->getRootDir();
146
147
        $loader->load($rootDir.'/config/config_'.$this->environment.'.yml');
148
149
        if (is_file($file = $rootDir.'/config/config_'.$this->environment.'.local.yml')) {
150
            $loader->load($file);
151
        }
152
    }
153
154
    /**
155
     * {@inheritdoc}
156
     */
157
    public function getCacheDir()
158
    {
159
        if ($this->isVagrantEnvironment()) {
160
            return '/dev/shm/sylius/cache/'.$this->environment;
161
        }
162
163
        return parent::getCacheDir();
164
    }
165
166
    /**
167
     * {@inheritdoc}
168
     */
169
    public function getLogDir()
170
    {
171
        if ($this->isVagrantEnvironment()) {
172
            return '/dev/shm/sylius/logs';
173
        }
174
175
        return parent::getLogDir();
176
    }
177
178
    /**
179
     * @return bool
180
     */
181
    protected function isVagrantEnvironment()
182
    {
183
        return (getenv('HOME') === '/home/vagrant' || getenv('VAGRANT') === 'VAGRANT') && is_dir('/dev/shm');
184
    }
185
}
186