1 | <?php |
||
19 | final class ResourceMetadataFactory |
||
20 | { |
||
21 | /** |
||
22 | * @internal |
||
23 | */ |
||
24 | const CACHE_PREFIX = 'elao.api_resources_metadata.metadata.'; |
||
25 | |||
26 | /** @var LoaderInterface[] */ |
||
27 | private $loaders; |
||
28 | |||
29 | /** |
||
30 | * Loaded metadata indexed by classname |
||
31 | * |
||
32 | * @var ResourceMetadata[] |
||
33 | */ |
||
34 | private $loadedClasses; |
||
35 | |||
36 | /** @var ResourceIndex */ |
||
37 | private $resourceIndex; |
||
38 | |||
39 | /** @var CacheItemPoolInterface|null */ |
||
40 | private $cache; |
||
41 | |||
42 | /** |
||
43 | * @param ResourceIndex $resourceIndex |
||
44 | * @param LoaderInterface[] $loaders |
||
45 | * @param CacheItemPoolInterface|null $cache |
||
46 | */ |
||
47 | public function __construct(ResourceIndex $resourceIndex, array $loaders, CacheItemPoolInterface $cache = null) |
||
54 | |||
55 | /** |
||
56 | * @param $value Resource class, instance, or short name |
||
57 | * |
||
58 | * @throws InvalidArgumentException When none of the loaders were able to guess information from |
||
59 | * |
||
60 | * @return ResourceMetadata |
||
61 | */ |
||
62 | public function getMetadataFor($value): ResourceMetadata |
||
99 | |||
100 | /** |
||
101 | * Gets a class name for a given class, instance or resource short name. |
||
102 | * |
||
103 | * @param string|object $value |
||
104 | * |
||
105 | * @throws InvalidArgumentException If it isn't a resource |
||
106 | * |
||
107 | * @return string The resource class |
||
108 | */ |
||
109 | private function getClass($value): string |
||
136 | } |
||
137 |