Conditions | 4 |
Paths | 5 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | public function getMetadata($classNameOrInstance): ApiResourceClassMetadata |
||
34 | { |
||
35 | $reflClass = new ReflectionClass($classNameOrInstance); |
||
36 | $annotation = $this->reader->getClassAnnotation( |
||
37 | $reflClass, |
||
38 | ApiResource::class |
||
39 | ); |
||
40 | if (!$annotation) { |
||
41 | throw new ApiResourceAnnotationNotFoundException($classNameOrInstance); |
||
42 | } |
||
43 | /** @var ApiResource $annotation */ |
||
44 | $retriever = null; |
||
45 | $persister = null; |
||
46 | if ($annotation->retrieveClass) { |
||
47 | $retriever = $this->retrieverFactory->getApiResourceRetrieverInstance($annotation->retrieveClass); |
||
48 | } |
||
49 | if ($annotation->persistClass) { |
||
50 | $persister = $this->retrieverFactory->getApiResourcePersisterInstance($annotation->persistClass); |
||
51 | } |
||
52 | |||
53 | return new ApiResourceClassMetadata($classNameOrInstance, $annotation, $retriever, $persister); |
||
54 | } |
||
56 |