Conditions | 2 |
Paths | 1 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function translator(array $dictionary) : void |
||
19 | { |
||
20 | |||
21 | $filter = new \Twig_SimpleFunction( |
||
22 | 'translate', |
||
23 | function ( |
||
24 | $string |
||
25 | ) use ($dictionary) { |
||
26 | if (array_key_exists($string, $dictionary)) { |
||
27 | return $dictionary[$string]; |
||
28 | } |
||
29 | return $string; |
||
30 | }, |
||
31 | array('is_safe' => array('html')) |
||
32 | ); |
||
33 | $this->twig->addFunction($filter); |
||
34 | } |
||
35 | } |