Completed
Push — master ( d39adb...94ce79 )
by Mateusz
10s
created

ServiceContainerExtension::setLoaderFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the ServiceContainerExtension package.
5
 *
6
 * (c) Kamil Kokot <[email protected]>
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 FriendsOfBehat\ServiceContainerExtension\ServiceContainer;
13
14
use Behat\Testwork\ServiceContainer\Extension;
15
use Behat\Testwork\ServiceContainer\ExtensionManager;
16
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
17
use Symfony\Component\Config\FileLocator;
18
use Symfony\Component\Config\Loader\DelegatingLoader;
19
use Symfony\Component\Config\Loader\LoaderInterface;
20
use Symfony\Component\Config\Loader\LoaderResolver;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
22
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
23
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
24
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
25
26
final class ServiceContainerExtension implements Extension
27
{
28
    /**
29
     * @var LoaderFactory
30
     */
31
    private $loaderFactory;
32
33
    public function __construct()
34
    {
35
        $this->loaderFactory = new DefaultLoaderFactory();
36
    }
37
38
    /**
39
     * @api
40
     *
41
     * @param LoaderFactory $loaderFactory
42
     */
43
    public function setLoaderFactory(LoaderFactory $loaderFactory)
44
    {
45
        $this->loaderFactory = $loaderFactory;
46
    }
47
48
    /**
49
     * @internal
50
     *
51
     * {@inheritdoc}
52
     */
53
    public function getConfigKey()
54
    {
55
        return 'fob_service_container';
56
    }
57
58
    /**
59
     * @internal
60
     *
61
     * {@inheritdoc}
62
     */
63
    public function initialize(ExtensionManager $extensionManager)
64
    {
65
    }
66
67
    /**
68
     * @internal
69
     *
70
     * {@inheritdoc}
71
     */
72
    public function configure(ArrayNodeDefinition $builder)
73
    {
74
        $builder
75
            ->children()
76
                ->arrayNode('imports')
77
                    ->performNoDeepMerging()
78
                    ->prototype('scalar')
79
        ;
80
    }
81
82
    /**
83
     * @internal
84
     *
85
     * {@inheritdoc}
86
     */
87
    public function load(ContainerBuilder $container, array $config)
88
    {
89
        $loader = $this->loaderFactory->createLoader($container, $config);
90
91
        foreach ($config['imports'] as $file) {
92
            $loader->load($file);
93
        }
94
    }
95
96
    /**
97
     * @internal
98
     *
99
     * {@inheritdoc}
100
     */
101
    public function process(ContainerBuilder $container)
102
    {
103
    }
104
}
105