1 | <?php |
||
25 | class Manager |
||
26 | { |
||
27 | /** |
||
28 | * Array of scope identifiers for resources to include. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $requestedIncludes = []; |
||
33 | |||
34 | /** |
||
35 | * Array of scope identifiers for resources to exclude. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $requestedExcludes = []; |
||
40 | |||
41 | /** |
||
42 | * Array of requested fieldsets. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $requestedFieldsets = []; |
||
47 | |||
48 | /** |
||
49 | * Array containing modifiers as keys and an array value of params. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $includeParams = []; |
||
54 | |||
55 | /** |
||
56 | * The character used to separate modifier parameters. |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | protected $paramDelimiter = '|'; |
||
61 | |||
62 | /** |
||
63 | * Upper limit to how many levels of included data are allowed. |
||
64 | * |
||
65 | * @var int |
||
66 | */ |
||
67 | protected $recursionLimit = 10; |
||
68 | |||
69 | /** |
||
70 | * Serializer. |
||
71 | * |
||
72 | * @var SerializerAbstract |
||
73 | */ |
||
74 | protected $serializer; |
||
75 | |||
76 | /** |
||
77 | * Create Data. |
||
78 | * |
||
79 | * Main method to kick this all off. Make a resource then pass it over, and use toArray() |
||
80 | * |
||
81 | * @param ResourceInterface $resource |
||
82 | * @param string $scopeIdentifier |
||
83 | * @param Scope $parentScopeInstance |
||
84 | * |
||
85 | * @return Scope |
||
86 | */ |
||
87 | 36 | public function createData(ResourceInterface $resource, $scopeIdentifier = null, Scope $parentScopeInstance = null) |
|
102 | |||
103 | /** |
||
104 | * Get Include Params. |
||
105 | * |
||
106 | * @param string $include |
||
107 | * |
||
108 | * @return \League\Fractal\ParamBag|null |
||
109 | */ |
||
110 | 27 | public function getIncludeParams($include) |
|
120 | |||
121 | /** |
||
122 | * Get Requested Includes. |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | 38 | public function getRequestedIncludes() |
|
130 | |||
131 | /** |
||
132 | * Get Requested Excludes. |
||
133 | * |
||
134 | * @return array |
||
135 | */ |
||
136 | 28 | public function getRequestedExcludes() |
|
140 | |||
141 | /** |
||
142 | * Get Serializer. |
||
143 | * |
||
144 | * @return SerializerAbstract |
||
145 | */ |
||
146 | 47 | public function getSerializer() |
|
154 | |||
155 | /** |
||
156 | * Parse Include String. |
||
157 | * |
||
158 | * @param array|string $includes Array or csv string of resources to include |
||
159 | * |
||
160 | * @return $this |
||
161 | */ |
||
162 | 41 | public function parseIncludes($includes) |
|
221 | |||
222 | /** |
||
223 | * Parse field parameter. |
||
224 | * |
||
225 | * @param array $fieldsets Array of fields to include. It must be an array |
||
226 | * whose keys are resource types and values a string |
||
227 | * of the fields to return, separated by a comma |
||
228 | * |
||
229 | * @return $this |
||
230 | */ |
||
231 | 13 | public function parseFieldsets(array $fieldsets) |
|
240 | |||
241 | /** |
||
242 | * Get requested fieldsets. |
||
243 | * |
||
244 | * @return array |
||
245 | */ |
||
246 | 1 | public function getRequestedFieldsets() |
|
250 | |||
251 | /** |
||
252 | * Get fieldset params for the specified type. |
||
253 | * |
||
254 | * @param string $type |
||
255 | * |
||
256 | * @return \League\Fractal\ParamBag|null |
||
257 | */ |
||
258 | 46 | public function getFieldset($type) |
|
264 | |||
265 | /** |
||
266 | * Parse Exclude String. |
||
267 | * |
||
268 | * @param array|string $excludes Array or csv string of resources to exclude |
||
269 | * |
||
270 | * @return $this |
||
271 | */ |
||
272 | 5 | public function parseExcludes($excludes) |
|
298 | |||
299 | /** |
||
300 | * Set Recursion Limit. |
||
301 | * |
||
302 | * @param int $recursionLimit |
||
303 | * |
||
304 | * @return $this |
||
305 | */ |
||
306 | 1 | public function setRecursionLimit($recursionLimit) |
|
312 | |||
313 | /** |
||
314 | * Set Serializer |
||
315 | * |
||
316 | * @param SerializerAbstract $serializer |
||
317 | * |
||
318 | * @return $this |
||
319 | */ |
||
320 | 47 | public function setSerializer(SerializerAbstract $serializer) |
|
326 | |||
327 | /** |
||
328 | * Auto-include Parents |
||
329 | * |
||
330 | * Look at the requested includes and automatically include the parents if they |
||
331 | * are not explicitly requested. E.g: [foo, bar.baz] becomes [foo, bar, bar.baz] |
||
332 | * |
||
333 | * @internal |
||
334 | * |
||
335 | * @return void |
||
336 | */ |
||
337 | 39 | protected function autoIncludeParents() |
|
355 | |||
356 | /** |
||
357 | * Trim to Acceptable Recursion Level |
||
358 | * |
||
359 | * Strip off any requested resources that are too many levels deep, to avoid DiCaprio being chased |
||
360 | * by trains or whatever the hell that movie was about. |
||
361 | * |
||
362 | * @internal |
||
363 | * |
||
364 | * @param string $includeName |
||
365 | * |
||
366 | * @return string |
||
367 | */ |
||
368 | 41 | protected function trimToAcceptableRecursionLevel($includeName) |
|
372 | } |
||
373 |