| Conditions | 5 |
| Paths | 6 |
| Total Lines | 31 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 6.0987 |
| Changes | 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 | $optionsArgumentIndex = 4; |
||
| 25 | } else { |
||
| 26 | 1 | $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 | } |
|
| 43 |