Completed
Pull Request — 0.4 (#35)
by jean
03:28
created

DarkilliantMqProcessExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 16
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A loadInternal() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Darkilliant\MqProcessBundle\DependencyInjection;
6
7
use PhpAmqpLib\Connection\AMQPLazyConnection;
8
use Symfony\Component\Config\FileLocator;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Definition;
11
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
12
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
13
14
class DarkilliantMqProcessExtension extends ConfigurableExtension
15
{
16
    protected function loadInternal(array $mergedConfig, ContainerBuilder $container)
17
    {
18
        $yamlLoader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
19
20
        $yamlLoader->load('services.yml');
21
22
        $connectionDefinition = new Definition(AMQPLazyConnection::class);
23
        $connectionDefinition->setArgument('$host', $mergedConfig['client']['host']);
24
        $connectionDefinition->setArgument('$port', $mergedConfig['client']['port']);
25
        $connectionDefinition->setArgument('$user', $mergedConfig['client']['user']);
26
        $connectionDefinition->setArgument('$password', $mergedConfig['client']['password']);
27
        $connectionDefinition->setArgument('$vhost', $mergedConfig['client']['vhost']);
28
29
        $container->setDefinition('darkilliant_mqprocess_connection', $connectionDefinition);
30
    }
31
}
32