FormTypePass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 16
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
4
namespace oliverde8\ComfyBundle\DependencyInjection\Compiler;
5
6
use oliverde8\ComfyBundle\Form\Type\ConfigsForm;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
class FormTypePass implements CompilerPassInterface
12
{
13
    /**
14
     * Register all data providers to the Manager.
15
     *
16
     * @param ContainerBuilder $container
17
     */
18
    public function process(ContainerBuilder $container)
19
    {
20
        if (!$container->has(ConfigsForm::class)) {
21
            return;
22
        }
23
        $definition = $container->getDefinition(ConfigsForm::class);
24
25
        // Find all config's
26
        $providerDefinitions = $container->findTaggedServiceIds('comfy.form_provider');
27
        $providerReferences = [];
28
29
        foreach ($providerDefinitions as $id => $tags) {
30
            $providerReferences[] = new Reference($id);
31
        }
32
33
        $definition->setArgument('$formTypeProviders', $providerReferences);
34
    }
35
}