Skip to content

Commit 72e37bc

Browse files
committed
v1.0 initial commit
0 parents  commit 72e37bc

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.phpdoc/
2+
docs/
3+
vendor/
4+
composer.lock
5+
.phpunit.result.cache

composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "micro/kernel-boot-plugin-depended",
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+
},
9+
"license": "MIT",
10+
"autoload": {
11+
"psr-4": {
12+
"Micro\\Framework\\Kernel\\": "src/"
13+
}
14+
},
15+
"authors": [
16+
{
17+
"name": "Stanislau Komar",
18+
"email": "[email protected]"
19+
}
20+
]
21+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the Micro framework package.
7+
*
8+
* (c) Stanislau Komar <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Micro\Framework\Kernel\Boot;
15+
16+
use Micro\Framework\Kernel\KernelInterface;
17+
use Micro\Framework\Kernel\Plugin\PluginBootLoaderInterface;
18+
use Micro\Framework\Kernel\Plugin\PluginDependedInterface;
19+
use Micro\Kernel\App\AppKernelInterface;
20+
21+
/**
22+
* @author Stanislau Komar <[email protected]>
23+
*/
24+
readonly class PluginDependedPluginsBootLoader implements PluginBootLoaderInterface
25+
{
26+
/**
27+
* @param AppKernelInterface $kernel
28+
*/
29+
public function __construct(
30+
private KernelInterface $kernel
31+
)
32+
{
33+
}
34+
35+
/**
36+
* {@inheritDoc}
37+
*/
38+
public function boot(object $applicationPlugin): void
39+
{
40+
if (!($applicationPlugin instanceof PluginDependedInterface)) {
41+
return;
42+
}
43+
44+
$dependedPlugins = $applicationPlugin->getDependedPlugins();
45+
if(!$dependedPlugins) {
46+
return;
47+
}
48+
49+
foreach ($dependedPlugins as $plugin) {
50+
$this->kernel->loadPlugin($plugin);
51+
}
52+
}
53+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the Micro framework package.
7+
*
8+
* (c) Stanislau Komar <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Micro\Framework\Kernel\Plugin;
15+
16+
/**
17+
* @author Stanislau Komar <[email protected]>
18+
*/
19+
interface PluginDependedInterface
20+
{
21+
/**
22+
* Returns a list of plugins that should be enabled in your application.
23+
*
24+
* @return iterable<class-string>
25+
*/
26+
public function getDependedPlugins(): iterable;
27+
}

0 commit comments

Comments
 (0)