|
2 | 2 |
|
3 | 3 | declare(strict_types=1); |
4 | 4 |
|
5 | | -namespace Setono\SyliusTermsPlugin\Tests\Application; |
| 5 | +namespace Tests\Setono\SyliusTermsPlugin\Application; |
6 | 6 |
|
7 | 7 | use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
8 | | -use Symfony\Component\HttpKernel\Bundle\BundleInterface; |
9 | 8 | use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
10 | | -use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; |
11 | 9 |
|
12 | 10 | final class Kernel extends BaseKernel |
13 | 11 | { |
14 | 12 | use MicroKernelTrait; |
15 | | - |
16 | | - private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
17 | | - |
18 | | - public function getCacheDir(): string |
19 | | - { |
20 | | - return $this->getProjectDir() . '/var/cache/' . $this->environment; |
21 | | - } |
22 | | - |
23 | | - public function getLogDir(): string |
24 | | - { |
25 | | - return $this->getProjectDir() . '/var/log'; |
26 | | - } |
27 | | - |
28 | | - public function registerBundles(): iterable |
29 | | - { |
30 | | - foreach ($this->getConfigurationDirectories() as $confDir) { |
31 | | - $bundlesFile = $confDir . '/bundles.php'; |
32 | | - if (false === is_file($bundlesFile)) { |
33 | | - continue; |
34 | | - } |
35 | | - yield from $this->registerBundlesFromFile($bundlesFile); |
36 | | - } |
37 | | - } |
38 | | - |
39 | | - protected function configureRoutes(RoutingConfigurator $routes): void |
40 | | - { |
41 | | - foreach ($this->getConfigurationDirectories() as $confDir) { |
42 | | - $this->loadRoutesConfiguration($routes, $confDir); |
43 | | - } |
44 | | - } |
45 | | - |
46 | | - private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void |
47 | | - { |
48 | | - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); |
49 | | - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); |
50 | | - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); |
51 | | - } |
52 | | - |
53 | | - /** |
54 | | - * @return BundleInterface[] |
55 | | - */ |
56 | | - private function registerBundlesFromFile(string $bundlesFile): iterable |
57 | | - { |
58 | | - $contents = require $bundlesFile; |
59 | | - foreach ($contents as $class => $envs) { |
60 | | - if (isset($envs['all']) || isset($envs[$this->environment])) { |
61 | | - yield new $class(); |
62 | | - } |
63 | | - } |
64 | | - } |
65 | | - |
66 | | - /** |
67 | | - * @return string[] |
68 | | - */ |
69 | | - private function getConfigurationDirectories(): iterable |
70 | | - { |
71 | | - yield $this->getProjectDir() . '/config'; |
72 | | - } |
73 | 13 | } |
0 commit comments