forked from Sylius/Sylius
/
Kernel.php
188 lines (163 loc) · 7.31 KB
/
Kernel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\CoreBundle\Application;
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\Config\FileLocator;
use Symfony\Component\HttpKernel\Kernel as HttpKernel;
use Webmozart\Assert\Assert;
class Kernel extends HttpKernel
{
public const VERSION = '1.1.3-DEV';
public const VERSION_ID = '10103';
public const MAJOR_VERSION = '1';
public const MINOR_VERSION = '1';
public const RELEASE_VERSION = '3';
public const EXTRA_VERSION = 'DEV';
/**
* {@inheritdoc}
*/
public function registerBundles(): array
{
$bundles = [
new \Sylius\Bundle\OrderBundle\SyliusOrderBundle(),
new \Sylius\Bundle\MoneyBundle\SyliusMoneyBundle(),
new \Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle(),
new \Sylius\Bundle\LocaleBundle\SyliusLocaleBundle(),
new \Sylius\Bundle\ProductBundle\SyliusProductBundle(),
new \Sylius\Bundle\ChannelBundle\SyliusChannelBundle(),
new \Sylius\Bundle\AttributeBundle\SyliusAttributeBundle(),
new \Sylius\Bundle\TaxationBundle\SyliusTaxationBundle(),
new \Sylius\Bundle\ShippingBundle\SyliusShippingBundle(),
new \Sylius\Bundle\PaymentBundle\SyliusPaymentBundle(),
new \Sylius\Bundle\MailerBundle\SyliusMailerBundle(),
new \Sylius\Bundle\PromotionBundle\SyliusPromotionBundle(),
new \Sylius\Bundle\AddressingBundle\SyliusAddressingBundle(),
new \Sylius\Bundle\InventoryBundle\SyliusInventoryBundle(),
new \Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle(),
new \Sylius\Bundle\UserBundle\SyliusUserBundle(),
new \Sylius\Bundle\CustomerBundle\SyliusCustomerBundle(),
new \Sylius\Bundle\UiBundle\SyliusUiBundle(),
new \Sylius\Bundle\ReviewBundle\SyliusReviewBundle(),
new \Sylius\Bundle\CoreBundle\SyliusCoreBundle(),
new \Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new \Sylius\Bundle\GridBundle\SyliusGridBundle(),
new \winzou\Bundle\StateMachineBundle\winzouStateMachineBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),
new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
new \Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Sonata\CoreBundle\SonataCoreBundle(),
new \Sonata\BlockBundle\SonataBlockBundle(),
new \Sonata\IntlBundle\SonataIntlBundle(),
new \Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),
new \JMS\SerializerBundle\JMSSerializerBundle(),
new \FOS\RestBundle\FOSRestBundle(),
new \Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
new \Knp\Bundle\MenuBundle\KnpMenuBundle(),
new \Liip\ImagineBundle\LiipImagineBundle(),
new \Payum\Bundle\PayumBundle\PayumBundle(),
new \Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new \WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new \Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new \Sylius\Bundle\FixturesBundle\SyliusFixturesBundle(),
new \Sylius\Bundle\PayumBundle\SyliusPayumBundle(), // must be added after PayumBundle.
new \Sylius\Bundle\ThemeBundle\SyliusThemeBundle(), // must be added after FrameworkBundle
new \Symfony\Bundle\WebServerBundle\WebServerBundle(), // allows to run build in web server. Not recommended for prod environment
];
if (in_array($this->getEnvironment(), ['dev', 'test', 'test_cached'], true)) {
$bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new \Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
}
return $bundles;
}
/**
* {@inheritdoc}
*/
protected function getContainerBaseClass(): string
{
if (in_array($this->getEnvironment(), ['test', 'test_cached'], true)) {
return MockerContainer::class;
}
return parent::getContainerBaseClass();
}
/**
* {@inheritdoc}
*/
protected function getContainerLoader(ContainerInterface $container): LoaderInterface
{
/** @var ContainerBuilder $container */
Assert::isInstanceOf($container, ContainerBuilder::class);
$locator = new FileLocator($this, $this->getRootDir() . '/Resources');
$resolver = new LoaderResolver([
new XmlFileLoader($container, $locator),
new YamlFileLoader($container, $locator),
new IniFileLoader($container, $locator),
new PhpFileLoader($container, $locator),
new DirectoryLoader($container, $locator),
new ClosureLoader($container),
]);
return new DelegatingLoader($resolver);
}
/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
$file = $this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.local.yml';
if (is_file($file)) {
$loader->load($file);
}
}
/**
* {@inheritdoc}
*/
public function getCacheDir(): string
{
if ($this->isVagrantEnvironment()) {
return '/dev/shm/sylius/cache/' . $this->getEnvironment();
}
return dirname($this->getRootDir()) . '/var/cache/' . $this->getEnvironment();
}
/**
* {@inheritdoc}
*/
public function getLogDir(): string
{
if ($this->isVagrantEnvironment()) {
return '/dev/shm/sylius/logs';
}
return dirname($this->getRootDir()) . '/var/logs';
}
/**
* @return bool
*/
protected function isVagrantEnvironment(): bool
{
return (getenv('HOME') === '/home/vagrant' || getenv('VAGRANT') === 'VAGRANT') && is_dir('/dev/shm');
}
}