1515
1616use MonsieurBiz \SyliusNoCommercePlugin \Kernel \SyliusNoCommerceKernelTrait ;
1717use PSS \SymfonyMockerContainer \DependencyInjection \MockerContainer ;
18- use Symfony \Component \Config \Loader \LoaderInterface ;
19- use Symfony \Component \Config \Resource \FileResource ;
20- use Symfony \Component \DependencyInjection \ContainerBuilder ;
2118use Symfony \Component \HttpKernel \Kernel as BaseKernel ;
22- use Symfony \Component \Routing \RouteCollectionBuilder ;
2319
2420final class Kernel extends BaseKernel
2521{
2622 use SyliusNoCommerceKernelTrait;
2723
28- private const CONFIG_EXTS = '.{php,xml,yaml,yml} ' ;
29-
30- public function getCacheDir (): string
31- {
32- return $ this ->getProjectDir () . '/var/cache/ ' . $ this ->environment ;
33- }
34-
35- public function getLogDir (): string
36- {
37- return $ this ->getProjectDir () . '/var/log ' ;
38- }
39-
40- public function registerBundles (): iterable
41- {
42- $ contents = require $ this ->getProjectDir () . '/config/bundles.php ' ;
43- foreach ($ contents as $ class => $ envs ) {
44- if (isset ($ envs ['all ' ]) || isset ($ envs [$ this ->environment ])) {
45- yield new $ class ();
46- }
47- }
48- }
49-
50- protected function configureContainer (ContainerBuilder $ container , LoaderInterface $ loader ): void
51- {
52- $ container ->addResource (new FileResource ($ this ->getProjectDir () . '/config/bundles.php ' ));
53- $ container ->setParameter ('container.dumper.inline_class_loader ' , true );
54- $ confDir = $ this ->getProjectDir () . '/config ' ;
55-
56- $ loader ->load ($ confDir . '/{packages}/* ' . self ::CONFIG_EXTS , 'glob ' );
57- $ loader ->load ($ confDir . '/{packages}/ ' . $ this ->environment . '/**/* ' . self ::CONFIG_EXTS , 'glob ' );
58- $ loader ->load ($ confDir . '/{services} ' . self ::CONFIG_EXTS , 'glob ' );
59- $ loader ->load ($ confDir . '/{services}_ ' . $ this ->environment . self ::CONFIG_EXTS , 'glob ' );
60- }
61-
62- protected function configureRoutes (RouteCollectionBuilder $ routes ): void
63- {
64- $ confDir = $ this ->getProjectDir () . '/config ' ;
65-
66- $ routes ->import ($ confDir . '/{routes}/* ' . self ::CONFIG_EXTS , '/ ' , 'glob ' );
67- $ routes ->import ($ confDir . '/{routes}/ ' . $ this ->environment . '/**/* ' . self ::CONFIG_EXTS , '/ ' , 'glob ' );
68- $ routes ->import ($ confDir . '/{routes} ' . self ::CONFIG_EXTS , '/ ' , 'glob ' );
69- }
70-
7124 protected function getContainerBaseClass (): string
7225 {
73- if ($ this ->isTestEnvironment ()) {
26+ if (class_exists (MockerContainer::class) && $ this ->isTestEnvironment ()) {
7427 return MockerContainer::class;
7528 }
7629
@@ -79,6 +32,6 @@ protected function getContainerBaseClass(): string
7932
8033 private function isTestEnvironment (): bool
8134 {
82- return 0 === strpos ($ this ->getEnvironment (), 'test ' );
35+ return str_starts_with ($ this ->getEnvironment (), 'test ' );
8336 }
8437}
0 commit comments