Completed
Push — master ( bd5d73...3bf673 )
by Yaroslav
01:42
created

LocalesConfigPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
c 1
b 1
f 0
lcom 0
cbo 1
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 2
1
<?php
2
3
namespace Harentius\BlogBundle\DependencyInjection\CompilerPass;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
class LocalesConfigPass implements CompilerPassInterface
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function process(ContainerBuilder $container)
14
    {
15
        $defaultLocale = $container->getParameter('kernel.default_locale');
16
        $locales = $container->getParameter('harentius_blog.locales');
17
        $supportedLocalesWithoutDefault = $locales;
18
19
        if (($key = array_search($defaultLocale, $supportedLocalesWithoutDefault)) !== false) {
20
            unset($supportedLocalesWithoutDefault[$key]);
21
        }
22
23
        $container->setParameter(
24
            'harentius_blog.supported_locales_without_default',
25
            implode('|', $supportedLocalesWithoutDefault)
26
        );
27
    }
28
}
29