Skip to content

Commit 06117ba

Browse files
author
Renato Marinho
authored
Merge pull request #252 from GitScrum-Community/develop
Custom serializer to transformer
2 parents 54ab125 + aab88d2 commit 06117ba

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Laravel GitScrum <https://github.com/GitScrum-Community/laravel-gitscrum>
4+
*
5+
* The MIT License (MIT)
6+
* Copyright (c) 2017 Renato Marinho <renato.marinho@s2move.com>
7+
*/
8+
9+
namespace GitScrum\Serializers;
10+
11+
use League\Fractal\Serializer\ArraySerializer;
12+
13+
class CustomSerializer extends ArraySerializer
14+
{
15+
/**
16+
* Serialize a collection.
17+
*
18+
* @param string $resourceKey
19+
* @param array $data
20+
*
21+
* @return array
22+
*/
23+
public function collection($resourceKey, array $data): array
24+
{
25+
return $data;
26+
}
27+
/**
28+
* Serialize an item.
29+
*
30+
* @param string $resourceKey
31+
* @param array $data
32+
*
33+
* @return array
34+
*/
35+
public function item($resourceKey, array $data): array
36+
{
37+
return $data;
38+
}
39+
/**
40+
* Serialize null resource.
41+
*
42+
* @return array
43+
*/
44+
public function null(): array
45+
{
46+
return [];
47+
}
48+
}

0 commit comments

Comments
 (0)