1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace KunicMarko\SonataAnnotationBundle\Features\Fixtures\Project; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
6
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
7
|
|
|
use Symfony\Component\Config\Resource\FileResource; |
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
9
|
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
10
|
|
|
use Symfony\Component\Routing\RouteCollectionBuilder; |
11
|
|
|
|
12
|
|
|
class Kernel extends BaseKernel |
13
|
|
|
{ |
14
|
|
|
use MicroKernelTrait; |
15
|
|
|
|
16
|
|
|
const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
17
|
|
|
|
18
|
|
|
public function getProjectDir() |
19
|
|
|
{ |
20
|
|
|
return __DIR__ . '/..'; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function getCacheDir() |
24
|
|
|
{ |
25
|
|
|
return $this->getProjectDir().'/var/cache/test'; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function getLogDir() |
29
|
|
|
{ |
30
|
|
|
return $this->getProjectDir().'/var/logs'; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function registerBundles() |
34
|
|
|
{ |
35
|
|
|
$contents = require $this->getProjectDir().'/config/bundles.php'; |
36
|
|
|
foreach ($contents as $class => $envs) { |
37
|
|
|
if (isset($envs['all']) || isset($envs[$this->environment])) { |
38
|
|
|
yield new $class(); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) |
44
|
|
|
{ |
45
|
|
|
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php')); |
46
|
|
|
$container->setParameter('container.autowiring.strict_mode', true); |
47
|
|
|
$container->setParameter('container.dumper.inline_class_loader', true); |
48
|
|
|
$loader->load($this->getProjectDir().'/config/packages/*.yaml', 'glob'); |
49
|
|
|
$loader->load($this->getProjectDir().'/config/services.yaml', 'glob'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
protected function configureRoutes(RouteCollectionBuilder $routes) |
53
|
|
|
{ |
54
|
|
|
$confDir = $this->getProjectDir().'/config'; |
55
|
|
|
|
56
|
|
|
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); |
57
|
|
|
$routes->import($confDir.'/{routes}/test/**/*'.self::CONFIG_EXTS, '/', 'glob'); |
58
|
|
|
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: