1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the CLIFramework package. |
5
|
|
|
* |
6
|
|
|
* (c) Arnaud VEBER <[email protected]> |
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 CLIFramework; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
15
|
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Kernel. |
19
|
|
|
*/ |
20
|
|
|
class Kernel extends BaseKernel |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Construct the kernel. |
24
|
|
|
* |
25
|
|
|
* @param string $environment |
26
|
|
|
* @param boolean $debug |
27
|
|
|
* |
28
|
|
|
* @return void |
|
|
|
|
29
|
|
|
*/ |
30
|
|
|
public function __construct($environment, $debug) |
31
|
|
|
{ |
32
|
|
|
parent::__construct($environment, $debug); |
33
|
|
|
|
34
|
|
|
// boot kernel |
35
|
|
|
$this->boot(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Register bundles. |
40
|
|
|
* |
41
|
|
|
* @return array |
|
|
|
|
42
|
|
|
*/ |
43
|
|
|
public function registerBundles() |
44
|
|
|
{ |
45
|
|
|
// register bundles for every environment |
46
|
|
|
$bundles = array( |
47
|
|
|
new \Symfony\Bundle\MonologBundle\MonologBundle(), |
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
// register bundles for dev & test environment only |
51
|
|
|
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) { |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $bundles; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Builds the service container. |
59
|
|
|
* |
60
|
|
|
* @return \Symfony\Component\DependencyInjection\TaggedContainerInterface The compiled service container |
|
|
|
|
61
|
|
|
* |
62
|
|
|
* @throws \RuntimeException |
63
|
|
|
*/ |
64
|
|
|
protected function buildContainer() |
65
|
|
|
{ |
66
|
|
|
$container = parent::buildContainer(); |
67
|
|
|
$container->setParameter('app.command.ids', array_keys($container->findTaggedServiceIds('app.command'))); |
68
|
|
|
|
69
|
|
|
return $container; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Register container configuration. |
74
|
|
|
* |
75
|
|
|
* @param \Symfony\Component\Config\Loader\LoaderInterface $loader |
76
|
|
|
* |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader) |
80
|
|
|
{ |
81
|
|
|
$loader->load(sprintf('%s/config/%s/config.yml', $this->getRootDir(), $this->getEnvironment())); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.