SleepnessUberOAuthRestExtension::getAlias()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Sleepness\UberOAuthRestBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\DefinitionDecorator;
6
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9
10
use Symfony\Component\Config\FileLocator;
11
12
class SleepnessUberOAuthRestExtension extends Extension
13
{
14
    public function load(array $configs, ContainerBuilder $container)
15
    {
16
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
17
        $loader->load('guzzle.xml');
18
        $loader->load('services.xml');
19
20
        $configuration = new Configuration();
21
        $config = $this->processConfiguration($configuration, $configs);
22
23
        $providers = $config['providers'];
24
25
        foreach ($providers as $name => $credentials) {
26
            $credentials['provider_name'] = $name;
27
28
            $class = $container->getParameter(sprintf('oauth_rest.provider.%s.class', $name), $name);
29
            $definition = new DefinitionDecorator('oauth_rest.provider.base');
30
            $definition->setClass($class);
31
            $definition->addMethodCall('setCredentials', [$credentials]);
32
33
            $container->setDefinition(sprintf('oauth_rest.provider.%s', $name), $definition);
34
        }
35
    }
36
37
    public function getAlias()
38
    {
39
        return 'oauth_rest';
40
    }
41
}
42