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