Skip to content

Commit 90c02ae

Browse files
committed
v1.0 release
0 parents  commit 90c02ae

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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": "[email protected]"
20+
}
21+
]
22+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
}

0 commit comments

Comments
 (0)