Completed
Push — master ( 0513f3...46cdfb )
by Daniel
03:05
created

RpcServicePass::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 4
1
<?php
2
3
namespace Cmobi\RabbitmqBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Definition;
8
9
class RpcServicePass implements CompilerPassInterface
10
{
11
    private $serviceName;
12
    private $serviceClass;
13
    private $queueOptions;
14
    private $params;
15
16
    public function __construct($serviceName, $serviceClass, array $queueOptions, array $params = [])
17
    {
18
        $this->serviceName = $serviceName;
19
        $this->serviceClass = $serviceClass;
20
        $this->queueOptions = $queueOptions;
21
        $this->params = $params;
22
    }
23
24
    public function process(ContainerBuilder $container)
25
    {
26
        $rpcHandler = $container->getDefinition('cmobi_rabbitmq.rpc.handler');
27
        $definition = new Definition(
28
            $this->serviceClass,
29
            [
30
                'handler' => $rpcHandler,
31
                'queueOptions' => $this->params,
32
                'parameters' => $this->queueOptions
33
            ]
34
        );
35
        $container->setDefinition($this->serviceName, $definition);
36
    }
37
}