Micro-PHP /
plugin-locator
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of the Micro framework package. |
||
| 5 | * |
||
| 6 | * (c) Stanislau Komar <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Micro\Plugin\Locator; |
||
| 13 | |||
| 14 | use Micro\Component\DependencyInjection\Container; |
||
| 15 | use Micro\Framework\Kernel\KernelInterface; |
||
| 16 | use Micro\Framework\Kernel\Plugin\DependencyProviderInterface; |
||
| 17 | use Micro\Plugin\Locator\Facade\LocatorFacade; |
||
| 18 | use Micro\Plugin\Locator\Facade\LocatorFacadeInterface; |
||
| 19 | use Micro\Plugin\Locator\Locator\LocatorFactory; |
||
| 20 | use Micro\Plugin\Locator\Locator\LocatorFactoryInterface; |
||
| 21 | |||
| 22 | class LocatorPlugin implements DependencyProviderInterface |
||
| 23 | { |
||
| 24 | private ?KernelInterface $kernel = null; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * {@inheritDoc} |
||
| 28 | */ |
||
| 29 | 1 | public function provideDependencies(Container $container): void |
|
| 30 | { |
||
| 31 | 1 | $container->register(LocatorFacadeInterface::class, function ( |
|
| 32 | 1 | KernelInterface $kernel |
|
| 33 | 1 | ) { |
|
| 34 | 1 | $this->kernel = $kernel; |
|
| 35 | |||
| 36 | 1 | return $this->createLocatorFacade(); |
|
| 37 | 1 | }); |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | protected function createLocatorFacade(): LocatorFacadeInterface |
|
| 41 | { |
||
| 42 | 1 | return new LocatorFacade( |
|
| 43 | 1 | $this->createLocatorFactory() |
|
| 44 | 1 | ); |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | protected function createLocatorFactory(): LocatorFactoryInterface |
|
| 48 | { |
||
| 49 | 1 | return new LocatorFactory($this->kernel); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 50 | } |
||
| 51 | } |
||
| 52 |