1 | <?php |
||
15 | trait OverridesFractal |
||
16 | { |
||
17 | /** |
||
18 | * Overrides Fractal's getter for available includes. |
||
19 | * |
||
20 | * @return array |
||
21 | */ |
||
22 | 18 | public function getAvailableIncludes() |
|
30 | |||
31 | /** |
||
32 | * Overrides Fractal's getter for default includes. |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | 18 | public function getDefaultIncludes() |
|
42 | |||
43 | /** |
||
44 | * Overrides Fractal's method for including a relation. |
||
45 | * |
||
46 | * @param \League\Fractal\Scope $scope |
||
47 | * @param string $identifier |
||
48 | * @param mixed $data |
||
49 | * @return \League\Fractal\Resource\ResourceInterface |
||
50 | */ |
||
51 | 10 | protected function callIncludeMethod(Scope $scope, $identifier, $data) |
|
57 | |||
58 | /** |
||
59 | * Resolve scoped includes for the given scope. |
||
60 | * |
||
61 | * @param \League\Fractal\Scope $scope |
||
62 | * @return array |
||
63 | */ |
||
64 | 1 | protected function resolveScopedIncludes(Scope $scope): array |
|
75 | |||
76 | /** |
||
77 | * Get the current scope of the transformer. |
||
78 | * |
||
79 | * @return \League\Fractal\Scope |
||
80 | */ |
||
81 | public abstract function getCurrentScope(); |
||
82 | |||
83 | /** |
||
84 | * Normalize relations to force a key value structure. |
||
85 | * |
||
86 | * @param array $relations |
||
87 | * @return array |
||
88 | */ |
||
89 | protected abstract function normalizeRelations(array $relations): array; |
||
90 | |||
91 | /** |
||
92 | * Include a related resource. |
||
93 | * |
||
94 | * @param string $identifier |
||
95 | * @param mixed $data |
||
96 | * @param array $parameters |
||
97 | * @return \League\Fractal\Resource\ResourceInterface |
||
98 | */ |
||
99 | protected abstract function includeResource(string $identifier, $data, array $parameters): ResourceInterface; |
||
100 | } |