Completed
Push — master ( b716f1...2f9340 )
by Kamil
18:43
created

SymfonyPageObjectExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 63
rs 10
c 3
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigKey() 0 4 1
A initialize() 0 3 1
A configure() 0 3 1
A load() 0 3 1
A process() 0 15 1
A getSymfonyApplicationServiceDefinition() 0 7 1
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