| Conditions | 4 |
| Paths | 4 |
| Total Lines | 29 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public function render(View $view) |
||
| 21 | { |
||
| 22 | $templateName = $view->getTemplate(); |
||
| 23 | $names = [ |
||
| 24 | $templateName, |
||
| 25 | sprintf('%s.html.twig', $templateName), |
||
| 26 | sprintf('%s.twig', $templateName), |
||
| 27 | ]; |
||
| 28 | |||
| 29 | foreach ($names as $name) { |
||
| 30 | try { |
||
| 31 | $template = $this->twig->loadTemplate($name); |
||
| 32 | break; |
||
| 33 | } catch (\Twig_Error_Loader $e) { |
||
|
|
|||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | if (!$template) { |
||
| 38 | throw new \InvalidArgumentException(sprintf( |
||
| 39 | 'Could not load template "%s", tried: "%s"', |
||
| 40 | $templateName, implode('", "', $names) |
||
| 41 | )); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $template->render([ |
||
| 45 | 'vars' => $view->getVars(), |
||
| 46 | 'value' => $view->getValue(), |
||
| 47 | ]); |
||
| 48 | } |
||
| 49 | } |
||
| 50 |