1
|
|
|
<?php |
2
|
|
|
namespace Yoanm\Behat3SymfonyExtension\ServiceContainer\SubExtension; |
3
|
|
|
|
4
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
5
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
8
|
|
|
use Yoanm\Behat3SymfonyExtension\ServiceContainer\Behat3SymfonyExtension; |
9
|
|
|
|
10
|
|
|
abstract class AbstractSubExtension implements CompilerPassInterface |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Returns the extension config key. |
14
|
|
|
* |
15
|
|
|
* @return string|false false in case no config |
16
|
|
|
*/ |
17
|
1 |
|
public function getConfigKey() |
18
|
|
|
{ |
19
|
1 |
|
return false; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Setups configuration for the extension. |
24
|
|
|
* |
25
|
|
|
* @param ArrayNodeDefinition $builder |
26
|
|
|
*/ |
27
|
|
|
public function configure(ArrayNodeDefinition $builder) |
28
|
|
|
{ |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Loads extension services into temporary container. |
33
|
|
|
* |
34
|
|
|
* @param ContainerBuilder $container |
35
|
|
|
* @param array $config |
36
|
|
|
*/ |
37
|
|
|
abstract public function load(ContainerBuilder $container, array $config); |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
1 |
|
public function process(ContainerBuilder $container) |
43
|
|
|
{ |
44
|
1 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param string $key |
48
|
|
|
* |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
12 |
|
protected function getContainerParamOrServiceId($key) |
52
|
|
|
{ |
53
|
12 |
|
return sprintf( |
54
|
12 |
|
'%s.%s', |
55
|
12 |
|
Behat3SymfonyExtension::BASE_CONTAINER_ID, |
56
|
|
|
$key |
57
|
12 |
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param ContainerBuilder $container |
62
|
|
|
* @param string $id |
63
|
|
|
* @param string $class |
64
|
|
|
* @param array $argumentList |
65
|
|
|
* @param array $tagList |
66
|
|
|
* @param array $addMethodCallList |
67
|
|
|
*/ |
68
|
8 |
|
protected function createService( |
69
|
|
|
ContainerBuilder $container, |
70
|
|
|
$id, |
71
|
|
|
$class, |
72
|
|
|
$argumentList = array(), |
73
|
|
|
$tagList = array(), |
74
|
|
|
$addMethodCallList = array() |
75
|
|
|
) { |
76
|
8 |
|
$definition = new Definition($class, $argumentList); |
77
|
|
|
|
78
|
8 |
|
foreach ($tagList as $tag) { |
79
|
5 |
|
$definition->addTag($tag); |
80
|
8 |
|
} |
81
|
|
|
|
82
|
8 |
|
foreach ($addMethodCallList as $methodCall) { |
83
|
2 |
|
$definition->addMethodCall($methodCall[0], $methodCall[1]); |
84
|
8 |
|
} |
85
|
|
|
|
86
|
8 |
|
$container->setDefinition($this->getContainerParamOrServiceId($id), $definition); |
87
|
8 |
|
} |
88
|
|
|
} |
89
|
|
|
|