RegisterEventHandlersPass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusPaginationPlugin\DependencyInjection\Compiler;
6
7
use Setono\SyliusPaginationPlugin\EventHandler\CompositeEventHandler;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Definition;
11
use Symfony\Component\DependencyInjection\Reference;
12
13
final class RegisterEventHandlersPass implements CompilerPassInterface
14
{
15
    public function process(ContainerBuilder $container): void
16
    {
17
        $compositeEventHandler = new Definition(CompositeEventHandler::class);
18
19
        foreach ($container->findTaggedServiceIds('setono_sylius_pagination.event_handler') as $id => $attributes) {
20
            $compositeEventHandler->addArgument(new Reference($id));
21
        }
22
23
        $container->setDefinition('setono_sylius_pagination.event_handler.composite', $compositeEventHandler);
24
    }
25
}
26