FormFactoryPass::process()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 24
rs 8.9713
cc 2
eloc 15
nc 2
nop 1
1
<?php
2
3
namespace DoS\ResourceBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class FormFactoryPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->hasParameter('dos.form.factory.class')) {
14
            return;
15
        }
16
17
        $class = $container->getParameter('dos.form.factory.class');
18
19
        $container->setParameter('form.facotry.class', $class);
20
        $container->getDefinition('form.factory')
21
            ->setClass($class)
22
            ->addMethodCall(
23
                'setSecurityTokenStorage',
24
                array(new Reference('security.token_storage'))
25
            )
26
            ->addMethodCall(
27
                'setPrefixAndReplacement',
28
                array(
29
                    $container->getParameter('dos.form.factory.override_pattern'),
30
                    $container->getParameter('dos.form.factory.override_replacement'),
31
                )
32
            )
33
        ;
34
    }
35
}
36