1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EzSystems\PlatformBehatBundle\ServiceContainer; |
4
|
|
|
|
5
|
|
|
use Behat\Behat\EventDispatcher\ServiceContainer\EventDispatcherExtension; |
6
|
|
|
use Behat\Symfony2Extension\ServiceContainer\Symfony2Extension; |
7
|
|
|
use Behat\Testwork\ServiceContainer\Extension; |
8
|
|
|
use Behat\Testwork\ServiceContainer\ExtensionManager; |
9
|
|
|
use eZ\Bundle\PlatformBehatBundle\Initializer\BehatSiteAccessInitializer; |
10
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
11
|
|
|
use Symfony\Component\Config\FileLocator; |
12
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
13
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
14
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
15
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* EzBehatExtension loads extension specific services. |
19
|
|
|
*/ |
20
|
|
|
class EzBehatExtension implements Extension |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
public function getConfigKey() |
26
|
|
|
{ |
27
|
|
|
return 'ezbehatextension'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
public function process(ContainerBuilder $container) |
34
|
|
|
{ |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function initialize(ExtensionManager $extensionManager) |
41
|
|
|
{ |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
|
|
public function configure(ArrayNodeDefinition $builder) |
48
|
|
|
{ |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Loads extension services into temporary container. |
53
|
|
|
* |
54
|
|
|
* @param ContainerBuilder $container |
55
|
|
|
* @param array $config |
56
|
|
|
*/ |
57
|
|
|
public function load(ContainerBuilder $container, array $config) |
58
|
|
|
{ |
59
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
60
|
|
|
$loader->load('services.yml'); |
61
|
|
|
|
62
|
|
|
$this->loadSiteAccessInitializer($container); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
private function loadSiteAccessInitializer(ContainerBuilder $container) |
66
|
|
|
{ |
67
|
|
|
$definition = new Definition(BehatSiteAccessInitializer::class); |
68
|
|
|
$definition->setArguments([ |
69
|
|
|
new Reference(Symfony2Extension::KERNEL_ID), |
70
|
|
|
]); |
71
|
|
|
$definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG, ['priority' => 0]); |
72
|
|
|
$container->setDefinition(BehatSiteAccessInitializer::class, $definition); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|