1 | <?php |
||
19 | class MetadataFactory |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Driver attached to this meta data factory |
||
24 | * @var \Drest\Mapping\Driver\DriverInterface $driver |
||
25 | */ |
||
26 | private $driver; |
||
27 | |||
28 | /** |
||
29 | * Cache used to prevent metadata reloading |
||
30 | * @var \Doctrine\Common\Cache\Cache $cache |
||
31 | */ |
||
32 | private $cache; |
||
33 | |||
34 | /** |
||
35 | * A prefix string to use when interacting with a Doctrine cache object |
||
36 | * @var string $cache_prefix |
||
37 | */ |
||
38 | private $cache_prefix = '_drest_'; |
||
39 | |||
40 | /** |
||
41 | * Metadata that has already been loaded by the driver |
||
42 | * @var array $loadedMetadata |
||
43 | */ |
||
44 | private $loadedMetadata = []; |
||
45 | |||
46 | /** |
||
47 | * @param DriverInterface $driver |
||
48 | */ |
||
49 | 51 | public function __construct(DriverInterface $driver) |
|
50 | { |
||
51 | 51 | $this->driver = $driver; |
|
52 | 51 | } |
|
53 | |||
54 | /** |
||
55 | * Set the doctrine cache drive to be user |
||
56 | * @param Cache $cache |
||
57 | */ |
||
58 | 31 | public function setCache(Cache $cache) |
|
62 | |||
63 | /** |
||
64 | * Get all class names |
||
65 | * @return array class names registered to this driver |
||
66 | */ |
||
67 | 2 | public function getAllClassNames() |
|
71 | |||
72 | /** |
||
73 | * Get metadata for a certain class - loads once and caches |
||
74 | * @param string $className |
||
75 | * @throws \Drest\DrestException |
||
76 | * @return ClassMetaData $metaData |
||
77 | */ |
||
78 | 50 | public function getMetadataForClass($className) |
|
114 | } |
||
115 |