1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Monsieur Biz' Rich Editor plugin for Sylius. |
5
|
|
|
* |
6
|
|
|
* (c) Monsieur Biz <[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
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace App; |
15
|
|
|
|
16
|
|
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
17
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
18
|
|
|
use Symfony\Component\Config\Resource\FileResource; |
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
20
|
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
21
|
|
|
use Symfony\Component\Routing\RouteCollectionBuilder; |
22
|
|
|
|
23
|
|
|
class Kernel extends BaseKernel |
24
|
|
|
{ |
25
|
|
|
use MicroKernelTrait; |
26
|
|
|
|
27
|
|
|
private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
28
|
|
|
|
29
|
|
|
public function registerBundles(): iterable |
30
|
|
|
{ |
31
|
|
|
$contents = require $this->getProjectDir() . '/config/bundles.php'; |
32
|
|
|
foreach ($contents as $class => $envs) { |
33
|
|
|
if ($envs[$this->environment] ?? $envs['all'] ?? false) { |
34
|
|
|
yield new $class(); |
|
|
|
|
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getProjectDir(): string |
40
|
|
|
{ |
41
|
|
|
return \dirname(__DIR__); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void |
45
|
|
|
{ |
46
|
|
|
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php')); |
47
|
|
|
$container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug); |
48
|
|
|
$container->setParameter('container.dumper.inline_factories', true); |
49
|
|
|
$confDir = $this->getProjectDir() . '/config'; |
50
|
|
|
|
51
|
|
|
$loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); |
52
|
|
|
$loader->load($confDir . '/{packages}/' . $this->environment . '/*' . self::CONFIG_EXTS, 'glob'); |
53
|
|
|
$loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); |
54
|
|
|
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
protected function configureRoutes(RouteCollectionBuilder $routes): void |
58
|
|
|
{ |
59
|
|
|
$confDir = $this->getProjectDir() . '/config'; |
60
|
|
|
|
61
|
|
|
$routes->import($confDir . '/{routes}/' . $this->environment . '/*' . self::CONFIG_EXTS, '/', 'glob'); |
62
|
|
|
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); |
63
|
|
|
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: