Completed
Push — master ( 21ab66...244a83 )
by Jacques
19s queued 12s
created

UiElementRegistryPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 3
nc 3
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace MonsieurBiz\SyliusRichEditorPlugin\DependencyInjection;
5
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
final class UiElementRegistryPass implements CompilerPassInterface
11
{
12
    public const UI_ELEMENT_SERVICE_TAG = 'monsieurbiz_rich_editor.ui_element';
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function process(ContainerBuilder $container): void
18
    {
19
        if (!$container->has('monsieurbiz_rich_editor.registry')) {
20
            return;
21
        }
22
23
        $uiElementRegistry = $container->findDefinition('monsieurbiz_rich_editor.registry');
24
25
        $taggedServices = $container->findTaggedServiceIds(self::UI_ELEMENT_SERVICE_TAG);
26
        foreach (array_keys($taggedServices) as $id) {
27
            $uiElementRegistry->addMethodCall('addUiElement', [new Reference($id)]);
28
        }
29
    }
30
}
31