Completed
Push — master ( 33f621...f1576d )
by Andreas
27:17
created

datamanagerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 21
ccs 12
cts 12
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 1
A get_prefix() 0 4 1
1
<?php
2
namespace midcom\bundle\dependencyInjection;
3
4
use Symfony\Component\DependencyInjection\ContainerBuilder;
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\Definition;
7
8
class datamanagerPass implements CompilerPassInterface
9
{
10 1
    public function process(ContainerBuilder $container)
11
    {
12 1
        $form_prefix = $this->get_prefix($container->getDefinition('form.factory'));
13
14
        $validator_builder = $container
15 1
            ->getDefinition('validator.builder')
16 1
            ->addMethodCall('addXmlMappings', [[$form_prefix . 'config/validation.xml']]);
17
18 1
        $container->getDefinition('translator')
19 1
            ->addArgument([
20 1
                $this->get_prefix($validator_builder, 'translations/validators.'),
21 1
                $form_prefix . 'translations/validators.'
22
            ]);
23 1
    }
24
25 1
    private static function get_prefix(Definition $service, string $suffix = '') : string
26
    {
27 1
        $rc = new \ReflectionClass($service->getClass());
28 1
        return dirname($rc->getFileName()) . '/Resources/' . $suffix;
29
    }
30
}