Translator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadCatalogue() 0 4 1
A initializeCatalogue() 0 13 3
1
<?php
2
3
namespace Sleepness\UberTranslationBundle\Translation;
4
5
use Symfony\Bundle\FrameworkBundle\Translation\Translator as BaseTranslator;
6
7
/**
8
 * Custom translator class
9
 *
10
 * @author Alexandr Zhulev <[email protected]>
11
 */
12
class Translator extends BaseTranslator
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    protected function loadCatalogue($locale)
18
    {
19
        $this->initializeCatalogue($locale);
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function initializeCatalogue($locale)
26
    {
27
        $memcached = $this->container->get('uber.memcached');
28
        $memcacheMessages = $memcached->getItem($locale);
29
        if ($memcacheMessages) {
30
            $domains = array_keys($memcacheMessages);
31
            foreach ($domains as $domain) {
32
                $this->addResource('memcached_loader', $memcached, $locale, $domain);
33
            }
34
        }
35
36
        parent::initializeCatalogue($locale);
37
    }
38
}
39