Completed
Push — ezp-30616 ( 9239a0...7bf8e8 )
by
unknown
57:53 queued 37:56
created

SignalSlotPass::process()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
cc 5
nc 5
nop 1
dl 17
loc 17
rs 9.3888
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the SignalSlotPass class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler;
10
11
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use LogicException;
14
use Symfony\Component\DependencyInjection\Reference;
15
16
/**
17
 * This compiler pass will register slots in SignalDispatcher.
18
 */
19 View Code Duplication
class SignalSlotPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    public function process(ContainerBuilder $container)
22
    {
23
        if (!$container->hasDefinition('ezpublish.signalslot.signal_dispatcher')) {
24
            return;
25
        }
26
27
        $signalDispatcherDef = $container->getDefinition('ezpublish.signalslot.signal_dispatcher');
28
        foreach ($container->findTaggedServiceIds('ezpublish.api.slot') as $id => $attributes) {
29
            foreach ($attributes as $attribute) {
30
                if (!isset($attribute['signal'])) {
31
                    throw new LogicException("Could not find 'signal' attribute on '$id' service, which is mandatory for services tagged as 'ezpublish.api.slot'");
32
                }
33
34
                $signalDispatcherDef->addMethodCall('attach', array($attribute['signal'], new Reference($id)));
35
            }
36
        }
37
    }
38
}
39