Completed
Push — master ( 62cfcc...2524ae )
by Joel
06:31
created

DependencyInjection/RedirectionIOExtension.php (1 issue)

1
<?php
2
3
namespace RedirectionIO\Client\ProxySymfony\DependencyInjection;
4
5
use RedirectionIO\Client\ProxySymfony\EventListener\RequestResponseListener;
6
use RedirectionIO\Client\Sdk\Client;
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
10
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
11
12
class RedirectionIOExtension extends Extension
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function load(array $configs, ContainerBuilder $container)
18
    {
19
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
20
        $loader->load('services.xml');
21
22
        $configuration = new Configuration();
23
        $config = $this->processConfiguration($configuration, $configs);
24
25
        foreach ($config['connections'] as $name => $connection) {
26
            $connections[$name] = $container->resolveEnvPlaceholders($connection);
27
        }
28
29
        $container
30
            ->getDefinition(Client::class)
31
            ->replaceArgument(0, $connections)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $connections seems to be defined by a foreach iteration on line 25. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
32
            ->replaceArgument(2, $config['debug'])
33
        ;
34
35
        $container
36
            ->getDefinition(RequestResponseListener::class)
37
            ->replaceArgument(1, $config['excluded_prefixes'])
38
        ;
39
    }
40
}
41