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 | 65 | 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 | 32 | 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|null |
||
107 | */ |
||
108 | 23 | public function getIncludeParams($include) |
|
118 | |||
119 | /** |
||
120 | * Get Requested Includes. |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | 34 | public function getRequestedIncludes() |
|
128 | |||
129 | /** |
||
130 | * Get Requested Excludes. |
||
131 | * |
||
132 | * @return array |
||
133 | */ |
||
134 | 24 | public function getRequestedExcludes() |
|
138 | |||
139 | /** |
||
140 | * Get Serializer. |
||
141 | * |
||
142 | * @return SerializerAbstract |
||
143 | */ |
||
144 | 41 | public function getSerializer() |
|
152 | |||
153 | /** |
||
154 | * Parse Include String. |
||
155 | * |
||
156 | * @param array|string $includes Array or csv string of resources to include |
||
157 | * |
||
158 | * @return $this |
||
159 | */ |
||
160 | 35 | public function parseIncludes($includes) |
|
219 | |||
220 | /** |
||
221 | * Parse Exclude String. |
||
222 | * |
||
223 | * @param array|string $excludes Array or csv string of resources to exclude |
||
224 | * |
||
225 | * @return $this |
||
226 | */ |
||
227 | 5 | public function parseExcludes($excludes) |
|
253 | |||
254 | /** |
||
255 | * Set Recursion Limit. |
||
256 | * |
||
257 | * @param int $recursionLimit |
||
258 | * |
||
259 | * @return $this |
||
260 | */ |
||
261 | 1 | public function setRecursionLimit($recursionLimit) |
|
267 | |||
268 | /** |
||
269 | * Set Serializer |
||
270 | * |
||
271 | * @param SerializerAbstract $serializer |
||
272 | * |
||
273 | * @return $this |
||
274 | */ |
||
275 | 41 | public function setSerializer(SerializerAbstract $serializer) |
|
281 | |||
282 | /** |
||
283 | * Auto-include Parents |
||
284 | * |
||
285 | * Look at the requested includes and automatically include the parents if they |
||
286 | * are not explicitly requested. E.g: [foo, bar.baz] becomes [foo, bar, bar.baz] |
||
287 | * |
||
288 | * @internal |
||
289 | * |
||
290 | * @return void |
||
291 | */ |
||
292 | 33 | protected function autoIncludeParents() |
|
310 | |||
311 | /** |
||
312 | * Trim to Acceptable Recursion Level |
||
313 | * |
||
314 | * Strip off any requested resources that are too many levels deep, to avoid DiCaprio being chased |
||
315 | * by trains or whatever the hell that movie was about. |
||
316 | * |
||
317 | * @internal |
||
318 | * |
||
319 | * @param string $includeName |
||
320 | * |
||
321 | * @return string |
||
322 | */ |
||
323 | 35 | protected function trimToAcceptableRecursionLevel($includeName) |
|
327 | } |
||
328 |