TranslationTrait::getContainer()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6667
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace ItBlaster\TranslationBundle\Traits;
4
5
/**
6
 * Вспомогательные методы для работы
7
 * с языковыми версиями
8
 *
9
 * Class TranslationTrait
10
 * @package ItBlaster\TranslationBundle\Trait
11
 */
12
trait TranslationTrait {
13
14
    protected $container;
15
16
    /**
17
     * Да да, тот самый контейнер, про который вы подумали
18
     *
19
     * @return mixed
20
     */
21
    protected function getContainer()
22
    {
23
        if (!$this->container) {
24
            $kernel = new \AppKernel('prod', false);
25
            $kernel->boot();
26
            $this->container = $kernel->getContainer();
27
        }
28
        return $this->container;
29
    }
30
31
    /**
32
     * Список локалей из конфига "it_blaster_translation.locales"
33
     *
34
     * @return array
35
     */
36
    protected function getLocales()
37
    {
38
        return $this->getContainer()->getParameter("it_blaster_translation.locales");
39
    }
40
41
    /**
42
     * Список локалей из конфига "it_blaster_translation.locales"
43
     *
44
     * @return array
45
     */
46
    protected function getSlugLocales()
47
    {
48
        return $this->getContainer()->getParameter("it_blaster_translation.slug_locales");
49
    }
50
}