Completed
Push — master ( 7d9afb...4e0ac6 )
by Łukasz
49:46 queued 21:48
created

NotificationRendererPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 1
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
4
 * @license For full copyright and license information view LICENSE file distributed with this source code.
5
 */
6
declare(strict_types=1);
7
8
namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler;
9
10
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symfony\Component\DependencyInjection\Reference;
13
14
/**
15
 * Adds all available export methods to registry.
16
 */
17
class NotificationRendererPass implements CompilerPassInterface
18
{
19
    /**
20
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
21
     */
22
    public function process(ContainerBuilder $container)
23
    {
24
        if (!$container->has('notification.renderer.registry')) {
25
            return;
26
        }
27
28
        $registry = $container->findDefinition('notification.renderer.registry');
29
30
        foreach ($container->findTaggedServiceIds('ezstudio.notification.renderer') as $id => $tags) {
31
            foreach ($tags as $tag) {
32
                $registry->addMethodCall('addRenderer', [$tag['alias'], new Reference($id)]);
33
            }
34
        }
35
    }
36
}
37