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

LocalesConfigPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 15
rs 9.4285
cc 2
eloc 9
nc 2
nop 1
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