1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Kreta package. |
5
|
|
|
* |
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
declare(strict_types=1); |
14
|
|
|
|
15
|
|
|
namespace Kreta\Notifier\Infrastructure\Symfony\Framework; |
16
|
|
|
|
17
|
|
|
use Http\HttplugBundle\HttplugBundle; |
18
|
|
|
use Nelmio\CorsBundle\NelmioCorsBundle; |
19
|
|
|
use OldSound\RabbitMqBundle\OldSoundRabbitMqBundle; |
20
|
|
|
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; |
21
|
|
|
use SimpleBus\SymfonyBridge\SimpleBusCommandBusBundle; |
22
|
|
|
use SimpleBus\SymfonyBridge\SimpleBusEventBusBundle; |
23
|
|
|
use Snc\RedisBundle\SncRedisBundle; |
24
|
|
|
use Symfony\Bundle\DebugBundle\DebugBundle; |
25
|
|
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; |
26
|
|
|
use Symfony\Bundle\MonologBundle\MonologBundle; |
27
|
|
|
use Symfony\Bundle\SecurityBundle\SecurityBundle; |
28
|
|
|
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle; |
29
|
|
|
use Symfony\Bundle\TwigBundle\TwigBundle; |
30
|
|
|
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle; |
31
|
|
|
use Symfony\Bundle\WebServerBundle\WebServerBundle; |
32
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
33
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
34
|
|
|
use Warezgibzzz\QueryBusBundle\WarezgibzzzQueryBusBundle; |
35
|
|
|
|
36
|
|
|
class AppKernel extends Kernel |
37
|
|
|
{ |
38
|
|
|
public function registerBundles() : array |
39
|
|
|
{ |
40
|
|
|
$bundles = [ |
41
|
|
|
new FrameworkBundle(), |
42
|
|
|
new HttplugBundle(), |
43
|
|
|
new MonologBundle(), |
44
|
|
|
new NelmioCorsBundle(), |
45
|
|
|
new OldSoundRabbitMqBundle(), |
46
|
|
|
new SecurityBundle(), |
47
|
|
|
new SimpleBusCommandBusBundle(), |
48
|
|
|
new SimpleBusEventBusBundle(), |
49
|
|
|
new SncRedisBundle(), |
50
|
|
|
new SwiftmailerBundle(), |
51
|
|
|
new WarezgibzzzQueryBusBundle(), |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
View Code Duplication |
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { |
|
|
|
|
55
|
|
|
$bundles[] = new DebugBundle(); |
56
|
|
|
|
57
|
|
|
if ('dev' === $this->getEnvironment()) { |
58
|
|
|
$bundles[] = new TwigBundle(); |
59
|
|
|
$bundles[] = new WebProfilerBundle(); |
60
|
|
|
$bundles[] = new WebServerBundle(); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
return $bundles; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getRootDir() : string |
68
|
|
|
{ |
69
|
|
|
return __DIR__; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getCacheDir() : string |
73
|
|
|
{ |
74
|
|
|
return dirname(__DIR__) . '/../../../../../var/cache/' . $this->getEnvironment(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getLogDir() : string |
78
|
|
|
{ |
79
|
|
|
return dirname(__DIR__) . '/../../../../../var/logs'; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader) : void |
83
|
|
|
{ |
84
|
|
|
$loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml'); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
protected function getContainerBaseClass() : string |
88
|
|
|
{ |
89
|
|
|
if ('test' === $this->environment) { |
90
|
|
|
return MockerContainer::class; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
return parent::getContainerBaseClass(); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.