1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the xAPI package. |
5
|
|
|
* |
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Xabbuh\XApi\Serializer; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Serializer\Encoder\JsonEncoder; |
15
|
|
|
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer; |
16
|
|
|
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; |
17
|
|
|
use Symfony\Component\Serializer\SerializerInterface; |
18
|
|
|
use Symfony\Component\Serializer\Serializer as SymfonySerializer; |
19
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\ActorNormalizer; |
20
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\DocumentDataNormalizer; |
21
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\ObjectNormalizer; |
22
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\ResultNormalizer; |
23
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\StatementNormalizer; |
24
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\StatementResultNormalizer; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Entry point to setup the {@link \Symfony\Component\Serializer\Serializer Symfony Serializer component} |
28
|
|
|
* for the Experience API. |
29
|
|
|
* |
30
|
|
|
* @author Christian Flothmann <[email protected]> |
31
|
|
|
*/ |
32
|
|
|
class Serializer |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* Creates a new Serializer. |
36
|
|
|
* |
37
|
|
|
* @return SerializerInterface The Serializer |
38
|
|
|
*/ |
39
|
24 |
|
public static function createSerializer() |
40
|
|
|
{ |
41
|
|
|
$normalizers = array( |
42
|
24 |
|
new ActorNormalizer(), |
43
|
24 |
|
new DocumentDataNormalizer(), |
44
|
24 |
|
new ObjectNormalizer(), |
45
|
24 |
|
new ResultNormalizer(), |
46
|
24 |
|
new StatementNormalizer(), |
47
|
24 |
|
new StatementResultNormalizer(), |
48
|
24 |
|
new ArrayDenormalizer(), |
49
|
24 |
|
new PropertyNormalizer(), |
50
|
|
|
); |
51
|
|
|
$encoders = array( |
52
|
24 |
|
new JsonEncoder(), |
53
|
|
|
); |
54
|
|
|
|
55
|
24 |
|
return new SymfonySerializer($normalizers, $encoders); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|