Conditions | 5 |
Paths | 6 |
Total Lines | 32 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5.3906 |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
10 | 1 | public function process(ContainerBuilder $container) |
|
11 | { |
||
12 | 1 | if (!$container->hasDefinition('incenteev_translation_checker.exposing_translator')) { |
|
13 | return; |
||
14 | } |
||
15 | |||
16 | 1 | if (!$container->has('translator.default')) { |
|
17 | return; |
||
18 | } |
||
19 | |||
20 | 1 | $translatorDef = $container->findDefinition('translator.default'); |
|
21 | |||
22 | // Symfony 3.3 added the default locale as third argument, before the loader ids and the options |
||
23 | 1 | if (is_string($translatorDef->getArgument(2))) { |
|
24 | 1 | $optionsArgumentIndex = 4; |
|
25 | } else { |
||
26 | $optionsArgumentIndex = 3; |
||
27 | } |
||
28 | |||
29 | 1 | $options = $translatorDef->getArgument($optionsArgumentIndex); |
|
30 | |||
31 | 1 | if (!is_array($options)) { |
|
32 | // Weird setup. Reset all options |
||
33 | $options = array(); |
||
34 | } |
||
35 | |||
36 | // use a separate cache as we have no fallback locales |
||
37 | 1 | $options['cache_dir'] = '%kernel.cache_dir%/incenteev_translations'; |
|
38 | |||
39 | 1 | $container->findDefinition('incenteev_translation_checker.exposing_translator') |
|
40 | 1 | ->replaceArgument($optionsArgumentIndex, $options); |
|
41 | 1 | } |
|
42 | } |
||
43 |