Completed
Pull Request — develop (#563)
by Narcotic
18:26 queued 13:29
created

Translator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 11
cp 0
cc 1
eloc 9
nc 1
nop 4
crap 2
1
<?php
2
/**
3
 * a small child of the symfony Translator in order to load more dynamically.
4
 * as we cannot inject more properties into this via DIC, our stuff is in I18nCacheUtils.
5
 */
6
7
namespace Graviton\I18nBundle\Translator;
8
9
use Symfony\Bundle\FrameworkBundle\Translation\Translator as BaseTranslator;
10
use Symfony\Component\Translation\MessageSelector;
11
use Symfony\Component\DependencyInjection\ContainerInterface;
12
13
/**
14
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
15
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
16
 * @link     http://swisscom.ch
17
 */
18
class Translator extends BaseTranslator
19
{
20
21
    /**
22
     * Constructor.
23
     *
24
     * Available options:
25
     *
26
     *   * cache_dir: The cache directory (or null to disable caching)
27
     *   * debug:     Whether to enable debugging or not (false by default)
28
     *   * resource_files: List of translation resources available grouped by locale.
29
     *
30
     * @param ContainerInterface $container A ContainerInterface instance
31
     * @param MessageSelector    $selector  The message selector for pluralization
32
     * @param array              $loaderIds An array of loader Ids
33
     * @param array              $options   An array of options
34
     *
35
     * @throws \InvalidArgumentException
36
     */
37
    public function __construct(
38
        ContainerInterface $container,
39
        MessageSelector $selector,
40
        $loaderIds = array(),
41
        array $options = array()
42
    ) {
43
44
        $options['resource_files'] = $container
45
            ->get('graviton.18n.cacheutils')
46
            ->getResources($options['resource_files']);
47
48
        parent::__construct($container, $selector, $loaderIds, $options);
49
    }
50
}
51