1 | <?php |
||
17 | trait OverridesFractal |
||
18 | { |
||
19 | /** |
||
20 | * Overrides Fractal's getter for available includes. |
||
21 | * |
||
22 | * @return array |
||
23 | */ |
||
24 | public function getAvailableIncludes() |
||
28 | |||
29 | /** |
||
30 | * Overrides Fractal's getter for default includes. |
||
31 | * |
||
32 | * @return array |
||
33 | */ |
||
34 | public function getDefaultIncludes() |
||
38 | |||
39 | /** |
||
40 | * Overrides Fractal's method for including a relation. |
||
41 | * |
||
42 | * @param \League\Fractal\Scope $scope |
||
43 | * @param string $relation |
||
44 | * @param mixed $data |
||
45 | * @return \League\Fractal\Resource\ResourceInterface |
||
46 | * @throws \LogicException |
||
47 | */ |
||
48 | protected function callIncludeMethod(Scope $scope, $relation, $data) |
||
60 | |||
61 | /** |
||
62 | * Get scoped parameters for a relation. |
||
63 | * |
||
64 | * @param \League\Fractal\Scope $scope |
||
65 | * @param string $relation |
||
66 | * @return \League\Fractal\ParamBag |
||
67 | */ |
||
68 | protected function getScopedParameters(Scope $scope, string $relation): ParamBag |
||
72 | |||
73 | /** |
||
74 | * Get the name of an existing include method. |
||
75 | * |
||
76 | * @param string $relation |
||
77 | * @return string|null |
||
78 | */ |
||
79 | protected function getIncludeMethod(string $relation) |
||
83 | |||
84 | /** |
||
85 | * Filter data using a filter method. |
||
86 | * |
||
87 | * @param mixed $data |
||
88 | * @param string $relation |
||
89 | * @return mixed |
||
90 | */ |
||
91 | protected function filterData($data, string $relation) |
||
100 | |||
101 | /** |
||
102 | * Get the name of an existing filter method. |
||
103 | * |
||
104 | * @param string $relation |
||
105 | * @return string|null |
||
106 | */ |
||
107 | protected function getFilterMethod(string $relation) |
||
111 | |||
112 | /** |
||
113 | * Make a related resource. |
||
114 | * |
||
115 | * @param string $relation |
||
116 | * @param mixed $data |
||
117 | * @return \League\Fractal\Resource\ResourceInterface|false |
||
118 | */ |
||
119 | protected abstract function makeResource(string $relation, $data); |
||
120 | } |