File tree Expand file tree Collapse file tree 3 files changed +78
-0
lines changed
Expand file tree Collapse file tree 3 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "name" : " micro/kernel-boot-loader-dependency" ,
3+ "description" : " Micro Framework: Kernel Boot loader - component to provide dependencies" ,
4+ "type" : " library" ,
5+ "version" : " 1.0" ,
6+ "require" : {
7+ "micro/kernel" : " ^1" ,
8+ "micro/autowire" : " ^1"
9+ },
10+ "license" : " MIT" ,
11+ "autoload" : {
12+ "psr-4" : {
13+ "Micro\\ Kernel\\ " : " src/"
14+ }
15+ },
16+ "authors" : [
17+ {
18+ "name" : " Stanislau Komar" ,
19+ "email" : " stanislau_komar@epam.com"
20+ }
21+ ]
22+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Micro \Framework \Kernel \Plugin \Boot ;
4+
5+ use Micro \Component \DependencyInjection \Autowire \ContainerAutowire ;
6+ use Micro \Component \DependencyInjection \Container ;
7+ use Micro \Framework \Kernel \Plugin \ApplicationPluginInterface ;
8+ use Micro \Framework \Kernel \Plugin \DependencyProviderInterface ;
9+ use Micro \Framework \Kernel \Plugin \PluginBootLoaderInterface ;
10+
11+ class DependencyProviderBootLoader implements PluginBootLoaderInterface
12+ {
13+ /**
14+ * @var Container
15+ */
16+ private readonly Container $ container ;
17+
18+ /**
19+ * @param Container $container
20+ */
21+ public function __construct (Container $ container )
22+ {
23+ if (!($ container instanceof ContainerAutowire)) {
24+ $ container = new ContainerAutowire ($ container );
25+ }
26+
27+ $ this ->container = $ container ;
28+ }
29+
30+ /**
31+ * {@inheritDoc}
32+ */
33+ public function boot (ApplicationPluginInterface $ applicationPlugin ): void
34+ {
35+ if (!($ applicationPlugin instanceof DependencyProviderInterface)) {
36+ return ;
37+ }
38+
39+ $ applicationPlugin ->provideDependencies ($ this ->container );
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Micro \Framework \Kernel \Plugin ;
4+
5+ use Micro \Component \DependencyInjection \Container ;
6+
7+ interface DependencyProviderInterface
8+ {
9+ /**
10+ * @param Container $container
11+ *
12+ * @return void
13+ */
14+ public function provideDependencies (Container $ container ): void ;
15+ }
You can’t perform that action at this time.
0 commit comments