Total Complexity | 5 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class RoutingLoader extends Loader |
||
13 | { |
||
14 | private bool $loaded = false; |
||
15 | |||
16 | public function __construct( |
||
17 | private ResourceRegistryInterface $resourceRegistry, |
||
18 | private ResourceLoaderInterface $resourceLoader, |
||
19 | ) { |
||
20 | parent::__construct(); |
||
21 | } |
||
22 | |||
23 | public function load($resource, string $type = null): RouteCollection |
||
24 | { |
||
25 | if ($this->loaded) { |
||
26 | throw new RuntimeException('Do not add the Admin routing loader "extra" twice'); |
||
27 | } |
||
28 | $routes = new RouteCollection(); |
||
29 | $resources = $this->resourceRegistry->all(); |
||
30 | |||
31 | foreach ($resources as $resource) { |
||
|
|||
32 | $this->resourceLoader->loadRoutes($resource, $routes); |
||
33 | } |
||
34 | |||
35 | return $routes; |
||
36 | } |
||
37 | |||
38 | public function supports($resource, string $type = null): bool |
||
41 | } |
||
42 | } |
||
43 |