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\Event\ActorEventSubscriber; |
20
|
|
|
use Xabbuh\XApi\Serializer\Event\DocumentDataWrapper; |
21
|
|
|
use Xabbuh\XApi\Serializer\Event\ObjectEventSubscriber; |
22
|
|
|
use Xabbuh\XApi\Serializer\Event\SetSerializedTypeEventSubscriber; |
23
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\ActorNormalizer; |
24
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\DocumentDataNormalizer; |
25
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\ObjectNormalizer; |
26
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\ResultNormalizer; |
27
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\StatementNormalizer; |
28
|
|
|
use Xabbuh\XApi\Serializer\Normalizer\StatementResultNormalizer; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Entry point to setup the {@link \Symfony\Component\Serializer\Serializer Symfony Serializer component} |
32
|
|
|
* for the Experience API. |
33
|
|
|
* |
34
|
|
|
* @author Christian Flothmann <[email protected]> |
35
|
|
|
*/ |
36
|
|
|
class Serializer |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* Creates a new Serializer. |
40
|
|
|
* |
41
|
|
|
* @return SerializerInterface The Serializer |
42
|
|
|
*/ |
43
|
|
|
public static function createSerializer() |
44
|
|
|
{ |
45
|
|
|
$normalizers = array( |
46
|
|
|
new ActorNormalizer(), |
47
|
|
|
new DocumentDataNormalizer(), |
48
|
|
|
new ObjectNormalizer(), |
49
|
|
|
new ResultNormalizer(), |
50
|
|
|
new StatementNormalizer(), |
51
|
|
|
new StatementResultNormalizer(), |
52
|
|
|
new ArrayDenormalizer(), |
53
|
|
|
new PropertyNormalizer(), |
54
|
|
|
); |
55
|
|
|
$encoders = array( |
56
|
|
|
new JsonEncoder(), |
57
|
|
|
); |
58
|
|
|
|
59
|
|
|
return new SymfonySerializer($normalizers, $encoders); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|