1111
1212namespace Symfony \Bundle \FrameworkBundle \Kernel ;
1313
14+ use Symfony \Bundle \FrameworkBundle \FrameworkBundle ;
1415use Symfony \Component \Config \Loader \LoaderInterface ;
1516use Symfony \Component \DependencyInjection \ContainerBuilder ;
1617use Symfony \Component \DependencyInjection \Loader \Configurator \AbstractConfigurator ;
@@ -48,7 +49,7 @@ trait MicroKernelTrait
4849 */
4950 private function configureContainer (ContainerConfigurator $ container , LoaderInterface $ loader , ContainerBuilder $ builder ): void
5051 {
51- $ configDir = $ this ->getConfigDir ();
52+ $ configDir = preg_replace ( ' {/config$} ' , ' /{config} ' , $ this ->getConfigDir () );
5253
5354 $ container ->import ($ configDir .'/{packages}/*.{php,yaml} ' );
5455 $ container ->import ($ configDir .'/{packages}/ ' .$ this ->environment .'/*.{php,yaml} ' );
@@ -73,7 +74,7 @@ private function configureContainer(ContainerConfigurator $container, LoaderInte
7374 */
7475 private function configureRoutes (RoutingConfigurator $ routes ): void
7576 {
76- $ configDir = $ this ->getConfigDir ();
77+ $ configDir = preg_replace ( ' {/config$} ' , ' /{config} ' , $ this ->getConfigDir () );
7778
7879 $ routes ->import ($ configDir .'/{routes}/ ' .$ this ->environment .'/*.{php,yaml} ' );
7980 $ routes ->import ($ configDir .'/{routes}/*.{php,yaml} ' );
@@ -84,7 +85,7 @@ private function configureRoutes(RoutingConfigurator $routes): void
8485 $ routes ->import ($ configDir .'/{routes}.php ' );
8586 }
8687
87- if (false !== ( $ fileName = (new \ReflectionObject ($ this ))->getFileName () )) {
88+ if ($ fileName = (new \ReflectionObject ($ this ))->getFileName ()) {
8889 $ routes ->import ($ fileName , 'attribute ' );
8990 }
9091 }
@@ -130,7 +131,13 @@ public function getLogDir(): string
130131
131132 public function registerBundles (): iterable
132133 {
133- $ contents = require $ this ->getBundlesPath ();
134+ if (!is_file ($ bundlesPath = $ this ->getBundlesPath ())) {
135+ yield new FrameworkBundle ();
136+
137+ return ;
138+ }
139+
140+ $ contents = require $ bundlesPath ;
134141 foreach ($ contents as $ class => $ envs ) {
135142 if ($ envs [$ this ->environment ] ?? $ envs ['all ' ] ?? false ) {
136143 yield new $ class ();
@@ -216,6 +223,8 @@ public function loadRoutes(LoaderInterface $loader): RouteCollection
216223 $ route ->setDefault ('_controller ' , ['kernel ' , $ controller [1 ]]);
217224 } elseif ($ controller instanceof \Closure && $ this === ($ r = new \ReflectionFunction ($ controller ))->getClosureThis () && !$ r ->isAnonymous ()) {
218225 $ route ->setDefault ('_controller ' , ['kernel ' , $ r ->name ]);
226+ } elseif ($ this ::class === $ controller && method_exists ($ this , '__invoke ' )) {
227+ $ route ->setDefault ('_controller ' , 'kernel ' );
219228 }
220229 }
221230
0 commit comments