1 | <?php |
||
21 | class ClassConfig |
||
22 | { |
||
23 | /** |
||
24 | * Config files are always re-generated when requested. |
||
25 | */ |
||
26 | const CACHE_NEVER = 0; |
||
27 | |||
28 | /** |
||
29 | * Config files are re-generated if older than the source (filemtime). |
||
30 | */ |
||
31 | const CACHE_VALIDATE = 1; |
||
32 | |||
33 | /** |
||
34 | * Config files are only generated once (or after being manually deleted). |
||
35 | */ |
||
36 | const CACHE_ALWAYS = 2; |
||
37 | |||
38 | /** |
||
39 | * Flag to determine whether the register() method has been called. |
||
40 | * |
||
41 | * @var bool |
||
42 | */ |
||
43 | protected static $registered = false; |
||
44 | |||
45 | /** |
||
46 | * In-memory cache for the annotation reader. |
||
47 | * |
||
48 | * @var AnnotationReader |
||
49 | */ |
||
50 | protected static $annotationReader; |
||
51 | |||
52 | /** |
||
53 | * The registered path to a cache folder. |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | protected static $cachePath; |
||
58 | |||
59 | /** |
||
60 | * The registered caching strategy. |
||
61 | * |
||
62 | * @var int |
||
63 | */ |
||
64 | protected static $cacheStrategy; |
||
65 | |||
66 | /** |
||
67 | * The registered class namespace for config classes. |
||
68 | * This will be used as prefix to source classes. |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | protected static $classNamespace; |
||
73 | |||
74 | /** |
||
75 | * A classmap of generated config files for the autoloader. |
||
76 | * |
||
77 | * @var string[] |
||
78 | */ |
||
79 | protected static $classmap; |
||
80 | |||
81 | /** |
||
82 | * A flag to determine that the classmap is dirty and should be written to the filesystem. |
||
83 | * |
||
84 | * @var bool |
||
85 | */ |
||
86 | protected static $classmapDirty = false; |
||
87 | |||
88 | /** |
||
89 | * @param string $path |
||
90 | */ |
||
91 | protected static function createDirectories(string $path) |
||
98 | |||
99 | /** |
||
100 | * Lazy getter for the annotation reader. |
||
101 | * |
||
102 | * @return AnnotationReader |
||
103 | * @throws \Doctrine\Common\Annotations\AnnotationException |
||
104 | */ |
||
105 | protected static function getAnnotationReader(): AnnotationReader |
||
112 | |||
113 | /** |
||
114 | * Getter for the registered cache path. |
||
115 | * Throws a ClassConfigNotRegisteredException if register() wasn't called prior. |
||
116 | * |
||
117 | * @return string |
||
118 | * @throws ClassConfigNotRegisteredException |
||
119 | */ |
||
120 | protected static function getCachePath(): string |
||
127 | |||
128 | /** |
||
129 | * Getter for the registered class namespace. |
||
130 | * Throws a ClassConfigNotRegisteredException if register() wasn't called prior. |
||
131 | * |
||
132 | * @return string |
||
133 | * @throws ClassConfigNotRegisteredException |
||
134 | */ |
||
135 | protected static function getClassNamespace(): string |
||
142 | |||
143 | /** |
||
144 | * @param Config $annotation |
||
145 | * @param string $className |
||
146 | * @param string $classNamespace |
||
147 | * @param string $targetClassNamespace |
||
148 | * @param string $targetCanonicalClassName |
||
149 | * @param int $time |
||
150 | * @param int $subClassIteration |
||
151 | * @return string |
||
152 | */ |
||
153 | protected static function generate( |
||
252 | |||
253 | /** |
||
254 | * Register the environment. |
||
255 | * This must be called once and only once (on each request) before working with the library. |
||
256 | * |
||
257 | * @param string $cachePath |
||
258 | * @param int $cacheStrategy |
||
259 | * @param string $classNamespace |
||
260 | */ |
||
261 | public static function register( |
||
308 | |||
309 | /** |
||
310 | * @param string $canonicalClassName |
||
311 | * @return string |
||
312 | * @throws \Doctrine\Common\Annotations\AnnotationException |
||
313 | * @throws \ReflectionException |
||
314 | * @throws ClassConfigNotRegisteredException |
||
315 | */ |
||
316 | public static function createClass(string $canonicalClassName): string |
||
368 | |||
369 | /** |
||
370 | * @param string $class |
||
371 | * @return AbstractConfig |
||
372 | * @throws \Doctrine\Common\Annotations\AnnotationException |
||
373 | * @throws \ReflectionException |
||
374 | * @throws ClassConfigNotRegisteredException |
||
375 | */ |
||
376 | public static function createInstance(string $class): AbstractConfig |
||
381 | } |