1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bankiru\Api\JsonRpc\Adapters\JMS\Compiler; |
4
|
|
|
|
5
|
|
|
use Bankiru\Api\JsonRpc\Adapters\JMS\RelationsHandler; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
8
|
|
|
|
9
|
|
|
final class RelationHandlerHelper |
10
|
|
|
{ |
11
|
1 |
|
public static function configureRelationHandler(ContainerBuilder $builder, $handler, $emid) |
12
|
|
|
{ |
13
|
1 |
|
if (!$builder->has($emid)) { |
14
|
1 |
|
return; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
$builder->register('jms_serializer.handler.relation', RelationsHandler::class) |
18
|
|
|
->setArguments([new Reference($emid)]) |
19
|
|
|
->addTag( |
20
|
|
|
'jms_serializer.handler', |
21
|
|
|
[ |
22
|
|
|
'type' => $handler, |
23
|
|
|
'direction' => 'serialization', |
24
|
|
|
'format' => 'json', |
25
|
|
|
'method' => 'serializeRelation', |
26
|
|
|
] |
27
|
|
|
) |
28
|
|
|
->addTag( |
29
|
|
|
'jms_serializer.handler', |
30
|
|
|
[ |
31
|
|
|
'type' => $handler, |
32
|
|
|
'direction' => 'deserialization', |
33
|
|
|
'format' => 'json', |
34
|
|
|
'method' => 'deserializeRelation', |
35
|
|
|
] |
36
|
|
|
) |
37
|
|
|
->addTag( |
38
|
|
|
'jms_serializer.handler', |
39
|
|
|
[ |
40
|
|
|
'type' => $handler . '<?>', |
41
|
|
|
'direction' => 'serialization', |
42
|
|
|
'format' => 'json', |
43
|
|
|
'method' => 'serializeRelation', |
44
|
|
|
] |
45
|
|
|
) |
46
|
|
|
->addTag( |
47
|
|
|
'jms_serializer.handler', |
48
|
|
|
[ |
49
|
|
|
'type' => $handler . '<?>', |
50
|
|
|
'direction' => 'deserialization', |
51
|
|
|
'format' => 'json', |
52
|
|
|
'method' => 'deserializeRelation', |
53
|
|
|
] |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|