1 | <?php |
||
16 | trait OverridesFractal |
||
17 | { |
||
18 | /** |
||
19 | * Overrides Fractal's getter for available includes. |
||
20 | * |
||
21 | * @return array |
||
22 | */ |
||
23 | public function getAvailableIncludes() |
||
31 | |||
32 | /** |
||
33 | * Overrides Fractal's getter for default includes. |
||
34 | * |
||
35 | * @return array |
||
36 | */ |
||
37 | public function getDefaultIncludes() |
||
41 | |||
42 | /** |
||
43 | * Overrides Fractal's method for including a relation. |
||
44 | * |
||
45 | * @param \League\Fractal\Scope $scope |
||
46 | * @param string $identifier |
||
47 | * @param mixed $data |
||
48 | * @return \League\Fractal\Resource\ResourceInterface |
||
49 | */ |
||
50 | protected function callIncludeMethod(Scope $scope, $identifier, $data) |
||
56 | |||
57 | /** |
||
58 | * Resolve scoped includes for the given scope. |
||
59 | * |
||
60 | * @param \League\Fractal\Scope $scope |
||
61 | * @return array |
||
62 | */ |
||
63 | protected function resolveScopedIncludes(Scope $scope): array |
||
74 | |||
75 | /** |
||
76 | * Resolve scoped parameters for the given scope. |
||
77 | * |
||
78 | * @param \League\Fractal\Scope $scope |
||
79 | * @param string $identifier |
||
80 | * @return array |
||
81 | */ |
||
82 | protected function resolveScopedParameters(Scope $scope, string $identifier): array |
||
86 | |||
87 | /** |
||
88 | * Get the current scope of the transformer. |
||
89 | * |
||
90 | * @return \League\Fractal\Scope |
||
91 | */ |
||
92 | public abstract function getCurrentScope(); |
||
93 | |||
94 | /** |
||
95 | * Indicates if all relations are allowed. |
||
96 | * |
||
97 | * @return bool |
||
98 | */ |
||
99 | public abstract function allowsAllRelations(): bool; |
||
100 | |||
101 | /** |
||
102 | * Get a list of whitelisted relations. |
||
103 | * |
||
104 | * @return string[] |
||
105 | */ |
||
106 | public abstract function getRelations(): array; |
||
107 | |||
108 | /** |
||
109 | * Get a list of default relations. |
||
110 | * |
||
111 | * @return string[] |
||
112 | */ |
||
113 | public abstract function getDefaultRelations(): array; |
||
114 | |||
115 | /** |
||
116 | * Include a related resource. |
||
117 | * |
||
118 | * @param string $identifier |
||
119 | * @param mixed $data |
||
120 | * @param array $parameters |
||
121 | * @return \League\Fractal\Resource\ResourceInterface |
||
122 | */ |
||
123 | protected abstract function includeResource(string $identifier, $data, array $parameters): ResourceInterface; |
||
124 | } |