1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NuvoleWeb\Drupal\DrupalExtension\ServiceContainer; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
6
|
|
|
use Symfony\Component\Config\FileLocator; |
7
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
8
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
9
|
|
|
use Drupal\DrupalExtension\ServiceContainer\DrupalExtension as OriginalDrupalExtension; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class DrupalExtension. |
13
|
|
|
* |
14
|
|
|
* @package NuvoleWeb\Drupal\DrupalExtension\ServiceContainer |
15
|
|
|
*/ |
16
|
|
|
class DrupalExtension extends OriginalDrupalExtension { |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
|
|
public function load(ContainerBuilder $container, array $config) { |
22
|
|
|
parent::load($container, $config); |
23
|
|
|
|
24
|
|
|
// Load default service definitions. |
25
|
|
|
$container_overrides = new ContainerBuilder(); |
26
|
|
|
$loader = new YamlFileLoader($container_overrides, new FileLocator(__DIR__ . '/../../..')); |
27
|
|
|
$loader->load('services.yml'); |
28
|
|
|
$container->merge($container_overrides); |
29
|
|
|
|
30
|
|
|
// Load custom service definitions. |
31
|
|
|
if ($config['services']) { |
32
|
|
|
$path_parts = pathinfo($config['services']); |
33
|
|
|
$container_overrides = new ContainerBuilder(); |
34
|
|
|
$loader = new YamlFileLoader($container_overrides, new FileLocator($path_parts['dirname'])); |
35
|
|
|
$loader->load($path_parts['basename']); |
36
|
|
|
$container->merge($container_overrides); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$this->loadContextInitializer($container); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Load context initializer. |
44
|
|
|
* |
45
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
46
|
|
|
* Service container instance. |
47
|
|
|
*/ |
48
|
|
|
private function loadContextInitializer(ContainerBuilder $container) { |
49
|
|
|
// Set current service container instance for service container initializer. |
50
|
|
|
$definition = $container->getDefinition('drupal.behat.context_initializer.service_container'); |
51
|
|
|
$definition->addArgument($container); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
|
|
public function configure(ArrayNodeDefinition $builder) { |
58
|
|
|
parent::configure($builder); |
59
|
|
|
|
60
|
|
|
// @codingStandardsIgnoreStart |
61
|
|
|
$builder-> |
62
|
|
|
children()-> |
63
|
|
|
scalarNode('services')-> |
64
|
|
|
defaultValue('')-> |
65
|
|
|
info('Path to service definition YAML file, e.g. "/path/to/my_services.yml". Services and parameters specified therein will override the original Behat Extension service definitions.')-> |
66
|
|
|
end()-> |
67
|
|
|
arrayNode('text')-> |
68
|
|
|
info( |
69
|
|
|
'Text strings, such as Log out or the Username field can be altered via behat.yml if they vary from the default values.' . PHP_EOL |
70
|
|
|
. ' log_out: "Sign out"' . PHP_EOL |
71
|
|
|
. ' log_in: "Sign in"' . PHP_EOL |
72
|
|
|
. ' password_field: "Enter your password"' . PHP_EOL |
73
|
|
|
. ' username_field: "Nickname"' . PHP_EOL |
74
|
|
|
. ' node_submit_label: "Save"' |
75
|
|
|
)-> |
76
|
|
|
addDefaultsIfNotSet()-> |
77
|
|
|
children()-> |
78
|
|
|
scalarNode('log_in')-> |
79
|
|
|
defaultValue('Log in')-> |
80
|
|
|
end()-> |
81
|
|
|
scalarNode('log_out')-> |
82
|
|
|
defaultValue('Log out')-> |
83
|
|
|
end()-> |
84
|
|
|
scalarNode('password_field')-> |
85
|
|
|
defaultValue('Password')-> |
86
|
|
|
end()-> |
87
|
|
|
scalarNode('username_field')-> |
88
|
|
|
defaultValue('Username')-> |
89
|
|
|
end()-> |
90
|
|
|
scalarNode('node_submit_label')-> |
91
|
|
|
defaultValue('Save')-> |
92
|
|
|
end()-> |
93
|
|
|
end()-> |
94
|
|
|
end()-> |
95
|
|
|
end(); |
96
|
|
|
// @codingStandardsIgnoreEnd |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
} |
100
|
|
|
|