1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the vseth-semesterly-reports project. |
5
|
|
|
* |
6
|
|
|
* (c) Florian Moser <[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
|
|
|
/* |
13
|
|
|
* This file is part of the symfony-template project. |
14
|
|
|
* |
15
|
|
|
* (c) Florian Moser <[email protected]> |
16
|
|
|
* |
17
|
|
|
* For the full copyright and license information, please view the LICENSE |
18
|
|
|
* file that was distributed with this source code. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace App; |
22
|
|
|
|
23
|
|
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
24
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
25
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
26
|
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
27
|
|
|
use Symfony\Component\Routing\RouteCollectionBuilder; |
28
|
|
|
|
29
|
|
|
class Kernel extends BaseKernel |
30
|
|
|
{ |
31
|
|
|
use MicroKernelTrait; |
32
|
|
|
|
33
|
|
|
const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
34
|
|
|
|
35
|
|
|
public function getCacheDir() |
36
|
|
|
{ |
37
|
|
|
return $this->getProjectDir() . '/var/cache/' . $this->environment; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function getLogDir() |
41
|
|
|
{ |
42
|
|
|
return $this->getProjectDir() . '/var/log'; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function registerBundles() |
46
|
|
|
{ |
47
|
|
|
$contents = require $this->getProjectDir() . '/config/bundles.php'; |
48
|
|
|
foreach ($contents as $class => $envs) { |
49
|
|
|
if (isset($envs['all']) || isset($envs[$this->environment])) { |
50
|
|
|
yield new $class(); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) |
56
|
|
|
{ |
57
|
|
|
$container->setParameter('container.autowiring.strict_mode', true); |
58
|
|
|
$container->setParameter('container.dumper.inline_class_loader', true); |
59
|
|
|
$confDir = $this->getProjectDir() . '/config'; |
60
|
|
|
$loader->load($confDir . '/packages/*' . self::CONFIG_EXTS, 'glob'); |
61
|
|
|
if (is_dir($confDir . '/packages/' . $this->environment)) { |
62
|
|
|
$loader->load($confDir . '/packages/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); |
63
|
|
|
} |
64
|
|
|
$loader->load($confDir . '/services' . self::CONFIG_EXTS, 'glob'); |
65
|
|
|
$loader->load($confDir . '/services_' . $this->environment . self::CONFIG_EXTS, 'glob'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
protected function configureRoutes(RouteCollectionBuilder $routes) |
69
|
|
|
{ |
70
|
|
|
$confDir = $this->getProjectDir() . '/config'; |
71
|
|
|
if (is_dir($confDir . '/routes/')) { |
72
|
|
|
$routes->import($confDir . '/routes/*' . self::CONFIG_EXTS, '/', 'glob'); |
73
|
|
|
} |
74
|
|
|
if (is_dir($confDir . '/routes/' . $this->environment)) { |
75
|
|
|
$routes->import($confDir . '/routes/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); |
76
|
|
|
} |
77
|
|
|
$routes->import($confDir . '/routes' . self::CONFIG_EXTS, '/', 'glob'); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: