ServicesPass::processListeners()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
nc 1
cc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of AppName.
5
 *
6
 * (c) Monofony
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 App\DependencyInjection\Compiler;
13
14
use App\EventListener\PasswordUpdaterListener;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
class ServicesPass implements CompilerPassInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function process(ContainerBuilder $container)
24
    {
25
        $this->processFactories($container);
26
        $this->processRepositories($container);
27
        $this->processListeners($container);
28
29
        $container->setAlias('sylius.context.customer', 'app.context.customer')->setPublic(true);
30
    }
31
32
    /**
33
     * @param ContainerBuilder $container
34
     */
35
    protected function processFactories(ContainerBuilder $container): void
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
    }
38
39
    /**
40
     * @param ContainerBuilder $container
41
     */
42
    protected function processFormTypes(ContainerBuilder $container): void
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
    {
44
    }
45
46
    /**
47
     * @param ContainerBuilder $container
48
     */
49
    protected function processRepositories(ContainerBuilder $container): void
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50
    {
51
    }
52
53
    /**
54
     * @param ContainerBuilder $container
55
     */
56
    private function processListeners(ContainerBuilder $container): void
57
    {
58
        $listenerPasswordUpdaterDefinition = $container->getDefinition('sylius.listener.password_updater');
59
        $listenerPasswordUpdaterDefinition
60
            ->setClass(PasswordUpdaterListener::class)
61
            ->addTag('kernel.event_listener', [
62
                'event' => 'sylius.customer.pre_update',
63
                'method' => 'customerUpdateEvent',
64
            ])
65
            ->addTag('kernel.event_listener', [
66
                'event' => 'sylius.admin_user.pre_update',
67
                'method' => 'genericEventUpdater',
68
            ]);
69
    }
70
}
71