Conditions | 4 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public function process(ContainerBuilder $container) |
||
23 | { |
||
24 | if (!$container->hasDefinition('translator.default')) { |
||
25 | return; |
||
26 | } |
||
27 | |||
28 | $translator = $container->findDefinition('translator.default') |
||
29 | ->setPublic(true); |
||
30 | |||
31 | $finder = Finder::create() |
||
32 | ->files() |
||
33 | ->filter(function (\SplFileInfo $file) { |
||
34 | return 2 === substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename()); |
||
35 | }) |
||
36 | ->in(__DIR__.'/../../../../translations') |
||
37 | ; |
||
38 | |||
39 | foreach ($finder as $file) { |
||
40 | list($domain, $locale, $format) = explode('.', $file->getBasename(), 3); |
||
41 | $translator->addMethodCall('addResource', [$format, (string) $file, $locale, $domain]); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 |