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 containing modifiers as keys and an array value of params. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $includeParams = []; |
||
47 | |||
48 | /** |
||
49 | * The character used to separate modifier parameters. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $paramDelimiter = '|'; |
||
54 | |||
55 | /** |
||
56 | * Upper limit to how many levels of included data are allowed. |
||
57 | * |
||
58 | * @var int |
||
59 | */ |
||
60 | protected $recursionLimit = 10; |
||
61 | |||
62 | /** |
||
63 | * Serializer. |
||
64 | * |
||
65 | * @var SerializerAbstract |
||
66 | */ |
||
67 | protected $serializer; |
||
68 | |||
69 | /** |
||
70 | * Factory used to create new configured scopes. |
||
71 | * |
||
72 | * @var ScopeFactoryInterface |
||
73 | */ |
||
74 | private $scopeFactory; |
||
75 | |||
76 | 69 | public function __construct(ScopeFactoryInterface $scopeFactory = null) |
|
80 | |||
81 | /** |
||
82 | * Create Data. |
||
83 | * |
||
84 | * Main method to kick this all off. Make a resource then pass it over, and use toArray() |
||
85 | * |
||
86 | * @param ResourceInterface $resource |
||
87 | * @param string $scopeIdentifier |
||
88 | * @param Scope $parentScopeInstance |
||
89 | * |
||
90 | * @return Scope |
||
91 | */ |
||
92 | 34 | public function createData(ResourceInterface $resource, $scopeIdentifier = null, Scope $parentScopeInstance = null) |
|
100 | |||
101 | /** |
||
102 | * Get Include Params. |
||
103 | * |
||
104 | * @param string $include |
||
105 | * |
||
106 | * @return \League\Fractal\ParamBag |
||
107 | */ |
||
108 | 25 | public function getIncludeParams($include) |
|
114 | |||
115 | /** |
||
116 | * Get Requested Includes. |
||
117 | * |
||
118 | * @return array |
||
119 | */ |
||
120 | 38 | public function getRequestedIncludes() |
|
124 | |||
125 | /** |
||
126 | * Get Requested Excludes. |
||
127 | * |
||
128 | * @return array |
||
129 | */ |
||
130 | 26 | public function getRequestedExcludes() |
|
134 | |||
135 | /** |
||
136 | * Get Serializer. |
||
137 | * |
||
138 | * @return SerializerAbstract |
||
139 | */ |
||
140 | 45 | public function getSerializer() |
|
148 | |||
149 | /** |
||
150 | * Parse Include String. |
||
151 | * |
||
152 | * @param array|string $includes Array or csv string of resources to include |
||
153 | * |
||
154 | * @return $this |
||
155 | */ |
||
156 | 37 | public function parseIncludes($includes) |
|
215 | |||
216 | /** |
||
217 | * Parse Exclude String. |
||
218 | * |
||
219 | * @param array|string $excludes Array or csv string of resources to exclude |
||
220 | * |
||
221 | * @return $this |
||
222 | */ |
||
223 | 5 | public function parseExcludes($excludes) |
|
249 | |||
250 | /** |
||
251 | * Set Recursion Limit. |
||
252 | * |
||
253 | * @param int $recursionLimit |
||
254 | * |
||
255 | * @return $this |
||
256 | */ |
||
257 | 1 | public function setRecursionLimit($recursionLimit) |
|
263 | |||
264 | /** |
||
265 | * Set Serializer |
||
266 | * |
||
267 | * @param SerializerAbstract $serializer |
||
268 | * |
||
269 | * @return $this |
||
270 | */ |
||
271 | 45 | public function setSerializer(SerializerAbstract $serializer) |
|
277 | |||
278 | /** |
||
279 | * Auto-include Parents |
||
280 | * |
||
281 | * Look at the requested includes and automatically include the parents if they |
||
282 | * are not explicitly requested. E.g: [foo, bar.baz] becomes [foo, bar, bar.baz] |
||
283 | * |
||
284 | * @internal |
||
285 | * |
||
286 | * @return void |
||
287 | */ |
||
288 | 35 | protected function autoIncludeParents() |
|
306 | |||
307 | /** |
||
308 | * Trim to Acceptable Recursion Level |
||
309 | * |
||
310 | * Strip off any requested resources that are too many levels deep, to avoid DiCaprio being chased |
||
311 | * by trains or whatever the hell that movie was about. |
||
312 | * |
||
313 | * @internal |
||
314 | * |
||
315 | * @param string $includeName |
||
316 | * |
||
317 | * @return string |
||
318 | */ |
||
319 | 37 | protected function trimToAcceptableRecursionLevel($includeName) |
|
323 | } |
||
324 |