1 | <?php |
||
18 | class JsonApiExtension implements ExtensionInterface |
||
19 | { |
||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | 2 | public function hydrate($object, $source, DocumentHydrator $hydrator) |
|
24 | { |
||
25 | 2 | if (! $object instanceof AbstractDocument) { |
|
26 | 1 | throw new InvalidDocumentException(sprintf( |
|
27 | 1 | 'Only top-level of document can contains "jsonapi"-object. Instance of "%s" given.', |
|
28 | get_class($object) |
||
29 | )); |
||
30 | } |
||
31 | |||
32 | 1 | $jsonApi = $this->createJsonApi($source, $hydrator); |
|
33 | |||
34 | 1 | $object->setJsonApi($jsonApi); |
|
35 | 1 | } |
|
36 | |||
37 | /** |
||
38 | * Create JsonAPI-object |
||
39 | * |
||
40 | * @param $source |
||
41 | * @param DocumentHydrator $hydrator |
||
42 | * @return JsonApiObject |
||
43 | */ |
||
44 | 1 | protected function createJsonApi($source, DocumentHydrator $hydrator): JsonApiObject |
|
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | 1 | public function supports(): array |
|
62 | } |