1 | <?php |
||
18 | abstract class SerializerAbstract |
||
19 | { |
||
20 | /** |
||
21 | * Serialize a collection. |
||
22 | * |
||
23 | * @param string $resourceKey |
||
24 | * @param array $data |
||
25 | * |
||
26 | * @return array |
||
27 | */ |
||
28 | abstract public function collection($resourceKey, array $data); |
||
29 | |||
30 | /** |
||
31 | * Serialize an item. |
||
32 | * |
||
33 | * @param string $resourceKey |
||
34 | * @param array $data |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | abstract public function item($resourceKey, array $data); |
||
39 | |||
40 | /** |
||
41 | * Serialize null resource. |
||
42 | * |
||
43 | * @param string $resourceKey |
||
44 | * |
||
45 | * @return array|null |
||
46 | */ |
||
47 | abstract public function null($resourceKey); |
||
48 | |||
49 | /** |
||
50 | * Serialize the included data. |
||
51 | * |
||
52 | * @param ResourceInterface $resource |
||
53 | * @param array $data |
||
54 | * |
||
55 | * @return array |
||
56 | */ |
||
57 | abstract public function includedData(ResourceInterface $resource, array $data); |
||
58 | |||
59 | /** |
||
60 | * Serialize the meta. |
||
61 | * |
||
62 | * @param array $meta |
||
63 | * |
||
64 | * @return array |
||
65 | */ |
||
66 | abstract public function meta(array $meta); |
||
67 | |||
68 | /** |
||
69 | * Serialize the paginator. |
||
70 | * |
||
71 | * @param PaginatorInterface $paginator |
||
72 | * |
||
73 | * @return array |
||
74 | */ |
||
75 | abstract public function paginator(PaginatorInterface $paginator); |
||
76 | |||
77 | /** |
||
78 | * Serialize the cursor. |
||
79 | * |
||
80 | * @param CursorInterface $cursor |
||
81 | * |
||
82 | * @return array |
||
83 | */ |
||
84 | abstract public function cursor(CursorInterface $cursor); |
||
85 | |||
86 | 33 | public function mergeIncludes($transformedData, $includedData) |
|
96 | |||
97 | /** |
||
98 | * Indicates if includes should be side-loaded. |
||
99 | * |
||
100 | * @return bool |
||
101 | */ |
||
102 | 16 | public function sideloadIncludes() |
|
106 | |||
107 | /** |
||
108 | * Hook for the serializer to inject custom data based on the relationships of the resource. |
||
109 | * |
||
110 | * @param array|null $data |
||
111 | * @param array $rawIncludedData |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | 1 | public function injectData($data, $rawIncludedData) |
|
119 | |||
120 | /** |
||
121 | * Hook for the serializer to modify the final list of includes. |
||
122 | * |
||
123 | * @param array $includedData |
||
124 | * @param array $data |
||
125 | * |
||
126 | * @return array |
||
127 | */ |
||
128 | 1 | public function filterIncludes($includedData, $data) |
|
132 | } |
||
133 |