Completed
Pull Request — master (#6)
by Pavel
14:37
created

JmsSerializerPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2.0014

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
ccs 13
cts 14
cp 0.9286
rs 9.3142
cc 2
eloc 11
nc 2
nop 1
crap 2.0014
1
<?php
2
3
namespace Bankiru\Api\JsonRpc\DependencyInjection\Compiler;
4
5
use Bankiru\Api\JsonRpc\Listener\SerializedJsonRpcResponseListener;
6
use Bankiru\Api\Rpc\RpcEvents;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
class JmsSerializerPass implements CompilerPassInterface
12
{
13
    /** {@inheritdoc} */
14 1
    public function process(ContainerBuilder $container)
15
    {
16 1
        if (!$container->has('jms_serializer')) {
17
            return;
18
        }
19
20 1
        $definition = $container->register('jsonrpc.view.serialize_response', SerializedJsonRpcResponseListener::class);
21 1
        $definition->setArguments(
22
            [
23 1
                new Reference('jms_serializer'),
24
            ]
25 1
        );
26 1
        $definition->addTag(
27 1
            'kernel.event_listener',
28
            [
29 1
                'event'    => RpcEvents::VIEW,
30 1
                'method'   => 'onPlainResponse',
31 1
                'priority' => -254,
32
            ]
33 1
        );
34 1
    }
35
}
36