1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Behatch; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
8
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
9
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
10
|
|
|
use Behat\Behat\Context\ServiceContainer\ContextExtension; |
11
|
|
|
use Behat\Testwork\ServiceContainer\ExtensionManager; |
12
|
|
|
use Behat\Testwork\ServiceContainer\Extension as ExtensionInterface; |
13
|
|
|
|
14
|
|
|
class Extension implements ExtensionInterface |
15
|
|
|
{ |
16
|
|
|
public function getConfigKey() |
17
|
|
|
{ |
18
|
|
|
return 'behatch'; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function initialize(ExtensionManager $extensionManager) |
22
|
|
|
{ |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function process(ContainerBuilder $container) |
26
|
|
|
{ |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function load(ContainerBuilder $container, array $config) |
30
|
|
|
{ |
31
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/Resources/services')); |
32
|
|
|
$loader->load('http_call.yml'); |
33
|
|
|
|
34
|
|
|
$this->loadClassResolver($container); |
35
|
|
|
$this->loadHttpCallListener($container); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function configure(ArrayNodeDefinition $builder) |
39
|
|
|
{ |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
private function loadClassResolver(ContainerBuilder $container) |
43
|
|
|
{ |
44
|
|
|
$definition = new Definition('Behatch\Context\ContextClass\ClassResolver'); |
45
|
|
|
$definition->addTag(ContextExtension::CLASS_RESOLVER_TAG); |
46
|
|
|
$container->setDefinition('behatch.class_resolver', $definition); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
private function loadHttpCallListener(ContainerBuilder $container) |
50
|
|
|
{ |
51
|
|
|
$processor = new \Behat\Testwork\ServiceContainer\ServiceProcessor; |
52
|
|
|
$references = $processor->findAndSortTaggedServices($container, 'behatch.context_voter'); |
53
|
|
|
$definition = $container->getDefinition('behatch.context_supported.voter'); |
54
|
|
|
|
55
|
|
|
foreach ($references as $reference) { |
56
|
|
|
$definition->addMethodCall('register', [$reference]); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getCompilerPasses() |
61
|
|
|
{ |
62
|
|
|
return []; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|