1 | <?php |
||
17 | class ResourceIndex |
||
18 | { |
||
19 | /** |
||
20 | * @internal |
||
21 | */ |
||
22 | const CACHE_KEY = 'elao.api_resources_metadata.indexed_resources'; |
||
23 | |||
24 | /** @var LocatorInterface[] */ |
||
25 | private $resourceLocators; |
||
26 | |||
27 | /** @var array */ |
||
28 | private $resourcesCache; |
||
29 | |||
30 | /** @var CacheItemPoolInterface|null */ |
||
31 | private $cache; |
||
32 | |||
33 | public function __construct(array $resourceLocators, CacheItemPoolInterface $cache = null) |
||
38 | |||
39 | /** |
||
40 | * @return array resources classes indexed by short name |
||
41 | */ |
||
42 | public function all(): array |
||
48 | |||
49 | /** |
||
50 | * @param string $resource Resource class or short name |
||
51 | * |
||
52 | * @return bool True if the class or short name identifies an existing resource |
||
53 | */ |
||
54 | public function has(string $resource): bool |
||
58 | |||
59 | /** |
||
60 | * @param string $resourceClass The resource FQCN |
||
61 | * |
||
62 | * @throws InvalidArgumentException When no resource found |
||
63 | * |
||
64 | * @return string The resource short name |
||
65 | */ |
||
66 | public function getShortName(string $resourceClass): string |
||
74 | |||
75 | /** |
||
76 | * @param string $shortName The resource short name |
||
77 | * |
||
78 | * @throws InvalidArgumentException When no resource found |
||
79 | * |
||
80 | * @return string The resource FQCN |
||
81 | */ |
||
82 | public function getResourceClass(string $shortName): string |
||
90 | |||
91 | private function locateResources() |
||
113 | } |
||
114 |