1 | <?php |
||
18 | class ArrayTransform extends AbstractTransform |
||
19 | { |
||
20 | /** |
||
21 | * Scope identifiers that resources can optionally include. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $includes = []; |
||
26 | |||
27 | /** |
||
28 | * Scope identifiers that resources must exclude. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $excludes = []; |
||
33 | |||
34 | /** |
||
35 | * Scope identifiers that resources must return. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $fields = []; |
||
40 | |||
41 | /** |
||
42 | * Auto-include Parents |
||
43 | * |
||
44 | * Look at the requested includes and automatically include the parents if they |
||
45 | * are not explicitly requested. E.g: [foo, bar.baz] becomes [foo, bar, bar.baz] |
||
46 | * |
||
47 | * @internal |
||
48 | * |
||
49 | * @return void |
||
50 | */ |
||
51 | protected function autoIncludeParents() |
||
69 | |||
70 | /******************************************* |
||
71 | * INCLUDES |
||
72 | *******************************************/ |
||
73 | |||
74 | /** |
||
75 | * Get Requested Includes. |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | public function getIncludes(): array |
||
83 | |||
84 | /** |
||
85 | * Parse Include String. |
||
86 | * |
||
87 | * @param array|string $includes Array or csv string of resources to include |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function setIncludes($includes) |
||
150 | |||
151 | /******************************************* |
||
152 | * EXCLUDES |
||
153 | *******************************************/ |
||
154 | |||
155 | /** |
||
156 | * Get Requested Excludes. |
||
157 | * |
||
158 | * @return array |
||
159 | */ |
||
160 | public function getExcludes(): array |
||
164 | |||
165 | /** |
||
166 | * Parse Exclude String. |
||
167 | * |
||
168 | * @param array|string $excludes Array or csv string of resources to exclude |
||
169 | * |
||
170 | * @return $this |
||
171 | */ |
||
172 | public function setExcludes($excludes) |
||
198 | |||
199 | /******************************************* |
||
200 | * FIELDS |
||
201 | *******************************************/ |
||
202 | |||
203 | /** |
||
204 | * Parse field parameter. |
||
205 | * |
||
206 | * @param array $fields Array of fields to include. It must be an array |
||
207 | * whose keys are resource types and values a string |
||
208 | * of the fields to return, separated by a comma |
||
209 | * |
||
210 | * @return $this |
||
211 | */ |
||
212 | public function setFields(array $fields) |
||
223 | |||
224 | /** |
||
225 | * Get requested fields. |
||
226 | * |
||
227 | * @return array |
||
228 | */ |
||
229 | public function getFields(): array |
||
233 | |||
234 | /** |
||
235 | * Get field params for the specified type. |
||
236 | * |
||
237 | * @param string $type |
||
238 | * |
||
239 | * @return ParamBag|null |
||
240 | */ |
||
241 | public function getField($type) |
||
247 | } |
||
248 |