1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Flugg\Responder\Serializers; |
4
|
|
|
|
5
|
|
|
use League\Fractal\Pagination\CursorInterface; |
6
|
|
|
use League\Fractal\Pagination\PaginatorInterface; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* A no-op serializer class responsible for returning the given data back untouched. |
10
|
|
|
* Only the raw transformed data is shown, this means meta data wont be visible. |
11
|
|
|
* The package uses this serializer for the [SimpleTransformer] and it's |
12
|
|
|
* practically an internal serializer, but feel free to use it elsewhere. |
13
|
|
|
* |
14
|
|
|
* @package flugger/laravel-responder |
15
|
|
|
* @author Alexander Tømmerås <[email protected]> |
16
|
|
|
* @license The MIT License |
17
|
|
|
*/ |
18
|
|
|
class NoopSerializer extends SuccessSerializer |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Serialize collection resources. |
22
|
|
|
* |
23
|
|
|
* @param string $resourceKey |
24
|
|
|
* @param array $data |
25
|
|
|
* @return array |
26
|
|
|
*/ |
27
|
1 |
|
public function collection($resourceKey, array $data) |
28
|
|
|
{ |
29
|
1 |
|
return $data; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Serialize item resources. |
34
|
|
|
* |
35
|
|
|
* @param string $resourceKey |
36
|
|
|
* @param array $data |
37
|
|
|
* @return array |
38
|
|
|
*/ |
39
|
1 |
|
public function item($resourceKey, array $data) |
40
|
|
|
{ |
41
|
1 |
|
return $data; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Serialize null resources. |
46
|
|
|
* |
47
|
|
|
* @return array |
48
|
|
|
*/ |
49
|
1 |
|
public function null() |
50
|
|
|
{ |
51
|
1 |
|
return null; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Format meta data. |
56
|
|
|
* |
57
|
|
|
* @param array $meta |
58
|
|
|
* @return array |
59
|
|
|
*/ |
60
|
1 |
|
public function meta(array $meta) |
61
|
|
|
{ |
62
|
1 |
|
return []; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Format pagination data. |
67
|
|
|
* |
68
|
|
|
* @param \League\Fractal\Pagination\PaginatorInterface $paginator |
69
|
|
|
* @return array |
70
|
|
|
*/ |
71
|
1 |
|
public function paginator(PaginatorInterface $paginator) |
72
|
|
|
{ |
73
|
1 |
|
return []; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Format cursor data. |
78
|
|
|
* |
79
|
|
|
* @param \League\Fractal\Pagination\CursorInterface $cursor |
80
|
|
|
* @return array |
81
|
|
|
*/ |
82
|
1 |
|
public function cursor(CursorInterface $cursor) |
83
|
|
|
{ |
84
|
1 |
|
return []; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Merge includes into data. |
89
|
|
|
* |
90
|
|
|
* @param array $transformedData |
91
|
|
|
* @param array $includedData |
92
|
|
|
* @return array |
93
|
|
|
*/ |
94
|
1 |
|
public function mergeIncludes($transformedData, $includedData) |
95
|
|
|
{ |
96
|
1 |
|
return array_merge($transformedData, $includedData); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|