| 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 | |||
| 20 | /** |
||
| 21 | * @author Stanislau Komar <[email protected]> |
||
| 22 | */ |
||
| 23 | readonly class DependedPluginsBootLoader implements PluginBootLoaderInterface |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 24 | { |
||
| 25 | 1 | public function __construct( |
|
| 26 | private KernelInterface $kernel |
||
| 27 | ) { |
||
| 28 | 1 | } |
|
| 29 | |||
| 30 | /** |
||
| 31 | * {@inheritDoc} |
||
| 32 | */ |
||
| 33 | 1 | public function boot(object $applicationPlugin): void |
|
| 34 | { |
||
| 35 | 1 | if (!($applicationPlugin instanceof PluginDependedInterface)) { |
|
| 36 | 1 | return; |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | $dependedPlugins = $applicationPlugin->getDependedPlugins(); |
|
| 40 | 1 | if (!$dependedPlugins) { |
|
| 41 | 1 | return; |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | foreach ($dependedPlugins as $plugin) { |
|
| 45 | 1 | $this->kernel->loadPlugin($plugin); |
|
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 |