|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sylius\Behat\SymfonyPageObjectExtension\ServiceContainer; |
|
13
|
|
|
|
|
14
|
|
|
use Behat\Testwork\ServiceContainer\Extension; |
|
15
|
|
|
use Behat\Testwork\ServiceContainer\ExtensionManager; |
|
16
|
|
|
use Sylius\Behat\SymfonyExtension\ServiceContainer\SymfonyExtension; |
|
17
|
|
|
use Sylius\Behat\SymfonyPageObjectExtension\Factory\SymfonyPageObjectFactory; |
|
18
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
21
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @author Kamil Kokot <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
class SymfonyPageObjectExtension implements Extension |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritdoc} |
|
30
|
|
|
*/ |
|
31
|
|
|
public function getConfigKey() |
|
32
|
|
|
{ |
|
33
|
|
|
return 'sylius_symfony_page_object'; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* {@inheritdoc} |
|
38
|
|
|
*/ |
|
39
|
|
|
public function initialize(ExtensionManager $extensionManager) |
|
40
|
|
|
{ |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
|
|
*/ |
|
46
|
|
|
public function configure(ArrayNodeDefinition $builder) |
|
47
|
|
|
{ |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* {@inheritdoc} |
|
52
|
|
|
*/ |
|
53
|
|
|
public function load(ContainerBuilder $container, array $config) |
|
54
|
|
|
{ |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritdoc} |
|
59
|
|
|
*/ |
|
60
|
|
|
public function process(ContainerBuilder $container) |
|
61
|
|
|
{ |
|
62
|
|
|
$container |
|
63
|
|
|
->register('sylius.page_object.factory', SymfonyPageObjectFactory::class) |
|
64
|
|
|
->setArguments([ |
|
65
|
|
|
new Reference('sylius.page_object.factory.inner'), |
|
66
|
|
|
new Reference('mink'), |
|
67
|
|
|
new Reference('sensio_labs.page_object_extension.class_name_resolver'), |
|
68
|
|
|
'%sensio_labs.page_object_extension.page_factory.page_parameters%', |
|
69
|
|
|
$this->getSymfonyApplicationServiceDefinition('router'), |
|
70
|
|
|
]) |
|
71
|
|
|
->setDecoratedService('sensio_labs.page_object_extension.page_factory') |
|
72
|
|
|
->setPublic(false) |
|
73
|
|
|
; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param string $serviceId |
|
78
|
|
|
* |
|
79
|
|
|
* @return Definition |
|
80
|
|
|
*/ |
|
81
|
|
|
private function getSymfonyApplicationServiceDefinition($serviceId) |
|
82
|
|
|
{ |
|
83
|
|
|
return (new Definition(null, [$serviceId]))->setFactory([ |
|
84
|
|
|
new Reference(SymfonyExtension::SHARED_KERNEL_CONTAINER_ID), |
|
85
|
|
|
'get', |
|
86
|
|
|
]); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|