| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class RoutingAnnotationLoader extends Loader |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var AnnotatedRouteControllerLoader |
||
| 15 | */ |
||
| 16 | private $annotatedRouteControllerLoader; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var bool |
||
| 20 | */ |
||
| 21 | private $isLoaded = false; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | private $configuration; |
||
| 27 | |||
| 28 | public function __construct(AnnotatedRouteControllerLoader $annotatedRouteController, array $configuration) |
||
| 29 | { |
||
| 30 | $this->annotatedRouteControllerLoader = $annotatedRouteController; |
||
| 31 | $this->configuration = $configuration; |
||
| 32 | } |
||
| 33 | |||
| 34 | public function load($resource, ?string $type = null): RouteCollection |
||
| 35 | { |
||
| 36 | if (true === $this->isLoaded) { |
||
| 37 | throw new RuntimeException('Do not add the "audit" loader twice'); |
||
| 38 | } |
||
| 39 | |||
| 40 | $routeCollection = new RouteCollection(); |
||
| 41 | if (true === $this->configuration['enabled_viewer']) { |
||
| 42 | $routeCollection = $this->annotatedRouteControllerLoader->load(ViewerController::class); |
||
| 43 | } |
||
| 44 | |||
| 45 | $this->isLoaded = true; |
||
| 46 | |||
| 47 | return $routeCollection; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function supports($resource, ?string $type = null): bool |
||
| 53 | } |
||
| 54 | } |
||
| 55 |