1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the ServiceContainerExtension package. |
5
|
|
|
* |
6
|
|
|
* (c) FriendsOfBehat |
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
|
|
|
/** |
27
|
|
|
* @author Kamil Kokot <[email protected]> |
28
|
|
|
*/ |
29
|
|
|
final class ServiceContainerExtension implements Extension |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var LoaderFactory |
33
|
|
|
*/ |
34
|
|
|
private $loaderFactory; |
35
|
|
|
|
36
|
|
|
public function __construct() |
37
|
|
|
{ |
38
|
|
|
$this->loaderFactory = new DefaultLoaderFactory(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @api |
43
|
|
|
* |
44
|
|
|
* @param LoaderFactory $loaderFactory |
45
|
|
|
*/ |
46
|
|
|
public function setLoaderCallable(LoaderFactory $loaderFactory) |
47
|
|
|
{ |
48
|
|
|
$this->loaderFactory = $loaderFactory; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @internal |
53
|
|
|
* |
54
|
|
|
* {@inheritdoc} |
55
|
|
|
*/ |
56
|
|
|
public function getConfigKey() |
57
|
|
|
{ |
58
|
|
|
return 'fob_service_container'; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @internal |
63
|
|
|
* |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
|
|
public function initialize(ExtensionManager $extensionManager) |
67
|
|
|
{ |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @internal |
73
|
|
|
* |
74
|
|
|
* {@inheritdoc} |
75
|
|
|
*/ |
76
|
|
|
public function configure(ArrayNodeDefinition $builder) |
77
|
|
|
{ |
78
|
|
|
$builder |
79
|
|
|
->children() |
80
|
|
|
->arrayNode('imports') |
81
|
|
|
->performNoDeepMerging() |
82
|
|
|
->prototype('scalar') |
83
|
|
|
; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @internal |
88
|
|
|
* |
89
|
|
|
* {@inheritdoc} |
90
|
|
|
*/ |
91
|
|
|
public function load(ContainerBuilder $container, array $config) |
92
|
|
|
{ |
93
|
|
|
$loader = $this->loaderFactory->createLoader($container, $config); |
94
|
|
|
|
95
|
|
|
foreach ($config['imports'] as $file) { |
96
|
|
|
$loader->load($file); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @internal |
102
|
|
|
* |
103
|
|
|
* {@inheritdoc} |
104
|
|
|
*/ |
105
|
|
|
public function process(ContainerBuilder $container) |
106
|
|
|
{ |
107
|
|
|
|
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|