File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ CHANGELOG
7
7
* Marked ` MicroKernelTrait::configureRoutes() ` as ` @internal ` and ` @final ` .
8
8
* Deprecated not overriding ` MicroKernelTrait::configureRouting() ` .
9
9
* Added a new ` mailer.message_bus ` option to configure or disable the message bus to use to send mails.
10
+ * Added flex-compatible default implementations for ` MicroKernelTrait::registerBundles() ` and ` getProjectDir() `
10
11
11
12
5.0.0
12
13
-----
Original file line number Diff line number Diff line change @@ -72,6 +72,27 @@ protected function configureRouting(RoutingConfigurator $routes): void
72
72
*/
73
73
abstract protected function configureContainer (ContainerBuilder $ c , LoaderInterface $ loader );
74
74
75
+ /**
76
+ * {@inheritdoc}
77
+ */
78
+ public function getProjectDir (): string
79
+ {
80
+ return \dirname ((new \ReflectionObject ($ this ))->getFileName (), 2 );
81
+ }
82
+
83
+ /**
84
+ * {@inheritdoc}
85
+ */
86
+ public function registerBundles (): iterable
87
+ {
88
+ $ contents = require $ this ->getProjectDir ().'/config/bundles.php ' ;
89
+ foreach ($ contents as $ class => $ envs ) {
90
+ if ($ envs [$ this ->environment ] ?? $ envs ['all ' ] ?? false ) {
91
+ yield new $ class ();
92
+ }
93
+ }
94
+ }
95
+
75
96
/**
76
97
* {@inheritdoc}
77
98
*/
@@ -100,8 +121,8 @@ public function registerContainerConfiguration(LoaderInterface $loader)
100
121
}
101
122
102
123
$ this ->configureContainer ($ container , $ loader );
103
-
104
124
$ container ->addObjectResource ($ this );
125
+ $ container ->fileExists ($ this ->getProjectDir ().'/config/bundles.php ' );
105
126
});
106
127
}
107
128
You can’t perform that action at this time.
0 commit comments