Completed
Push — master ( e63237...cdb730 )
by Jarek
11s
created

ValidationCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 17
c 1
b 0
f 0
rs 9.4285
cc 3
eloc 9
nc 3
nop 1
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\Bundle\AdminSecurityBundle\DependencyInjection\Compiler;
11
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
14
15
class ValidationCompilerPass implements CompilerPassInterface
16
{
17
    /**
18
     * {@inheritDoc}
19
     */
20
    public function process(ContainerBuilder $container)
21
    {
22
        if (!$container->hasParameter('admin_security.storage')) {
23
            return;
24
        }
25
26
        if (!$container->hasDefinition('validator.builder')) {
27
            return;
28
        }
29
30
        $storage = $container->getParameter('admin_security.storage');
31
32
        $validationFile = __DIR__ . '/../../Resources/config/storage-validation/' . $storage . '.xml';
33
34
        $container->getDefinition('validator.builder')
35
            ->addMethodCall('addXmlMapping', [$validationFile]);
36
    }
37
}
38