Completed
Push — master ( 8b479a...c1c0ed )
by Kamil
18:11
created

Symfony2Extension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 51
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigKey() 0 4 1
A initialize() 0 12 2
A configure() 0 3 1
A load() 0 5 1
A process() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Behat\Symfony2Extension\ServiceContainer;
13
14
use Behat\MinkExtension\ServiceContainer\MinkExtension;
15
use Behat\Symfony2Extension\ServiceContainer\Symfony2Extension as BaseSymfony2Extension;
16
use Behat\Testwork\ServiceContainer\Extension;
17
use Behat\Testwork\ServiceContainer\ExtensionManager;
18
use Sylius\Behat\Symfony2Extension\Factory\IsolatedSymfonyFactory;
19
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
22
/**
23
 * @author Kamil Kokot <[email protected]>
24
 */
25
final class Symfony2Extension implements Extension
26
{
27
    const DRIVER_KERNEL_ID = 'sylius_symfony2_extension.kernel';
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getConfigKey()
33
    {
34
        return 'sylius_symfony2';
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function initialize(ExtensionManager $extensionManager)
41
    {
42
        /** @var MinkExtension $minkExtension */
43
        $minkExtension = $extensionManager->getExtension('mink');
44
        if (null === $minkExtension) {
45
            return;
46
        }
47
48
        // Overrides default Symfony2Extension driver factory
49
        // Have to be registered after that one
50
        $minkExtension->registerDriverFactory(new IsolatedSymfonyFactory());
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function configure(ArrayNodeDefinition $builder)
57
    {
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function load(ContainerBuilder $container, array $config)
64
    {
65
        // Duplicates application kernel in order to separate contexts' container from driver's container
66
        $container->setDefinition(self::DRIVER_KERNEL_ID, $container->getDefinition(BaseSymfony2Extension::KERNEL_ID));
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function process(ContainerBuilder $container)
73
    {
74
    }
75
}
76