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\Business\Locator; |
||
| 15 | |||
| 16 | use Micro\Framework\Kernel\KernelInterface; |
||
| 17 | use Micro\Plugin\Http\Facade\HttpFacadeInterface; |
||
| 18 | use Micro\Plugin\Http\Plugin\RouteProviderPluginInterface; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @author Stanislau Komar <[email protected]> |
||
| 22 | */ |
||
| 23 | readonly class RouteCodeLocator implements RouteLocatorInterface |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 24 | { |
||
| 25 | 3 | public function __construct( |
|
| 26 | private KernelInterface $kernel, |
||
| 27 | private HttpFacadeInterface $httpFacade |
||
| 28 | ) { |
||
| 29 | 3 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * {@inheritDoc} |
||
| 33 | */ |
||
| 34 | 2 | public function locate(): iterable |
|
| 35 | { |
||
| 36 | 2 | $iterator = $this->kernel->plugins(RouteProviderPluginInterface::class); |
|
| 37 | /** @var RouteProviderPluginInterface $plugin */ |
||
| 38 | 2 | foreach ($iterator as $plugin) { |
|
| 39 | 2 | foreach ($plugin->provideRoutes($this->httpFacade) as $route) { |
|
| 40 | 2 | yield $route; |
|
| 41 | } |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 |