daikon-cqrs /
boot
| 1 | <?php declare(strict_types=1); |
||
| 2 | /** |
||
| 3 | * This file is part of the daikon-cqrs/boot project. |
||
| 4 | * |
||
| 5 | * For the full copyright and license information, please view the LICENSE |
||
| 6 | * file that was distributed with this source code. |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace Daikon\Boot\Config; |
||
| 10 | |||
| 11 | use Aura\Router\RouterContainer; |
||
| 12 | use Daikon\Config\ConfigLoaderInterface; |
||
| 13 | use Daikon\Config\ConfigProviderInterface; |
||
| 14 | |||
| 15 | final class RoutingConfigLoader implements ConfigLoaderInterface |
||
| 16 | { |
||
| 17 | private RouterContainer $router; |
||
| 18 | |||
| 19 | private ConfigProviderInterface $configProvider; |
||
| 20 | |||
| 21 | public function __construct(RouterContainer $router, ConfigProviderInterface $configProvider) |
||
| 22 | { |
||
| 23 | $this->router = $router; |
||
| 24 | $this->configProvider = $configProvider; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function load(array $locations, array $sources): array |
||
| 28 | { |
||
| 29 | $router = $this->router; |
||
| 30 | //these variables are in scope for included routing files |
||
| 31 | $map = $router->getMap(); |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 32 | $configProvider = $this->configProvider; |
||
|
0 ignored issues
–
show
|
|||
| 33 | |||
| 34 | $loadedConfigs = []; |
||
| 35 | foreach ($locations as $location) { |
||
| 36 | if (substr($location, -1) !== '/') { |
||
| 37 | $location .= '/'; |
||
| 38 | } |
||
| 39 | foreach ($sources as $source) { |
||
| 40 | $filepath = $location.$source; |
||
| 41 | if (is_file($filepath) && is_readable($filepath)) { |
||
| 42 | require_once $filepath; |
||
| 43 | $loadedConfigs[] = $filepath; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | return $loadedConfigs; |
||
| 49 | } |
||
| 50 | } |
||
| 51 |