7
7
use PSS \SymfonyMockerContainer \DependencyInjection \MockerContainer ;
8
8
use Sylius \Bundle \CoreBundle \Application \Kernel as SyliusKernel ;
9
9
use Symfony \Bundle \FrameworkBundle \Kernel \MicroKernelTrait ;
10
- use Symfony \Component \Config \Loader \DelegatingLoader ;
11
10
use Symfony \Component \Config \Loader \LoaderInterface ;
12
- use Symfony \Component \Config \Loader \LoaderResolver ;
13
11
use Symfony \Component \Config \Resource \FileResource ;
14
12
use Symfony \Component \DependencyInjection \ContainerBuilder ;
15
- use Symfony \Component \DependencyInjection \ContainerInterface ;
16
- use Symfony \Component \DependencyInjection \Loader \ClosureLoader ;
17
- use Symfony \Component \DependencyInjection \Loader \DirectoryLoader ;
18
- use Symfony \Component \DependencyInjection \Loader \GlobFileLoader ;
19
- use Symfony \Component \DependencyInjection \Loader \IniFileLoader ;
20
- use Symfony \Component \DependencyInjection \Loader \PhpFileLoader ;
21
- use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
22
- use Symfony \Component \DependencyInjection \Loader \YamlFileLoader ;
23
13
use Symfony \Component \HttpKernel \Bundle \BundleInterface ;
24
- use Symfony \Component \HttpKernel \Config \FileLocator ;
25
14
use Symfony \Component \HttpKernel \Kernel as BaseKernel ;
26
15
use Symfony \Component \Routing \RouteCollectionBuilder ;
27
- use Webmozart \Assert \Assert ;
28
16
29
17
final class Kernel extends BaseKernel
30
18
{
@@ -45,14 +33,22 @@ public function getLogDir(): string
45
33
public function registerBundles (): iterable
46
34
{
47
35
foreach ($ this ->getConfigurationDirectories () as $ confDir ) {
48
- yield from $ this ->registerBundlesFromFile ($ confDir . '/bundles.php ' );
36
+ $ bundlesFile = $ confDir . '/bundles.php ' ;
37
+ if (false === is_file ($ bundlesFile )) {
38
+ continue ;
39
+ }
40
+ yield from $ this ->registerBundlesFromFile ($ bundlesFile );
49
41
}
50
42
}
51
43
52
44
protected function configureContainer (ContainerBuilder $ container , LoaderInterface $ loader ): void
53
45
{
54
46
foreach ($ this ->getConfigurationDirectories () as $ confDir ) {
55
- $ container ->addResource (new FileResource ($ confDir . '/bundles.php ' ));
47
+ $ bundlesFile = $ confDir . '/bundles.php ' ;
48
+ if (false === is_file ($ bundlesFile )) {
49
+ continue ;
50
+ }
51
+ $ container ->addResource (new FileResource ($ bundlesFile ));
56
52
}
57
53
58
54
$ container ->setParameter ('container.dumper.inline_class_loader ' , true );
@@ -117,6 +113,13 @@ private function registerBundlesFromFile(string $bundlesFile): iterable
117
113
private function getConfigurationDirectories (): iterable
118
114
{
119
115
yield $ this ->getProjectDir () . '/config ' ;
120
- yield $ this ->getProjectDir () . '/config/sylius/ ' . SyliusKernel::MAJOR_VERSION . '. ' . SyliusKernel::MINOR_VERSION ;
116
+ $ syliusConfigDir = $ this ->getProjectDir () . '/config/sylius/ ' . SyliusKernel::MAJOR_VERSION . '. ' . SyliusKernel::MINOR_VERSION ;
117
+ if (is_dir ($ syliusConfigDir )) {
118
+ yield $ syliusConfigDir ;
119
+ }
120
+ $ symfonyConfigDir = $ this ->getProjectDir () . '/config/symfony/ ' . BaseKernel::MAJOR_VERSION . '. ' . BaseKernel::MINOR_VERSION ;
121
+ if (is_dir ($ symfonyConfigDir )) {
122
+ yield $ symfonyConfigDir ;
123
+ }
121
124
}
122
125
}
0 commit comments