Micro-PHP /
http-router-code
| 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\Plugin\Http; |
||
| 15 | |||
| 16 | use Micro\Component\DependencyInjection\Container; |
||
| 17 | use Micro\Framework\Kernel\KernelInterface; |
||
| 18 | use Micro\Framework\Kernel\Plugin\DependencyProviderInterface; |
||
| 19 | use Micro\Framework\Kernel\Plugin\PluginDependedInterface; |
||
| 20 | use Micro\Plugin\Http\Business\Locator\RouteCodeLocator; |
||
| 21 | use Micro\Plugin\Http\Business\Locator\RouteLocatorInterface; |
||
| 22 | use Micro\Plugin\Http\Facade\HttpFacadeInterface; |
||
| 23 | use Micro\Plugin\Http\Plugin\HttpRouteLocatorPluginInterface; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @author Stanislau Komar <[email protected]> |
||
| 27 | */ |
||
| 28 | readonly class HttpRouterCodePlugin implements HttpRouteLocatorPluginInterface, DependencyProviderInterface, PluginDependedInterface |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 29 | { |
||
| 30 | /** |
||
| 31 | * @phpstan-ignore-next-line |
||
| 32 | */ |
||
| 33 | private Container $container; |
||
| 34 | |||
| 35 | 6 | public function provideDependencies(Container $container): void |
|
| 36 | { |
||
| 37 | // @phpstan-ignore-next-line |
||
| 38 | 6 | $this->container = $container; |
|
| 39 | } |
||
| 40 | |||
| 41 | 2 | public function getLocatorType(): string |
|
| 42 | { |
||
| 43 | 2 | return 'code'; |
|
| 44 | } |
||
| 45 | |||
| 46 | 2 | public function createLocator(): RouteLocatorInterface |
|
| 47 | { |
||
| 48 | 2 | $kernel = $this->container->get(KernelInterface::class); |
|
| 49 | 2 | $httpFacade = $this->container->get(HttpFacadeInterface::class); |
|
| 50 | // @phpstan-ignore-next-line |
||
| 51 | 2 | return new RouteCodeLocator($kernel, $httpFacade); |
|
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritDoc} |
||
| 56 | */ |
||
| 57 | 2 | public function getDependedPlugins(): iterable |
|
| 58 | { |
||
| 59 | 2 | return [ |
|
| 60 | 2 | HttpCorePlugin::class, |
|
| 61 | 2 | ]; |
|
| 62 | } |
||
| 63 | } |
||
| 64 |