| 1 | <?php |
||
| 10 | class TwigFormatter extends HtmlFormatter |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var Twig_Environment |
||
| 14 | */ |
||
| 15 | protected $environment; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @param Twig_Environment $environment |
||
| 19 | * @param Httpstatus $httpStatus |
||
| 20 | */ |
||
| 21 | 3 | public function __construct(Twig_Environment $environment, Httpstatus $httpStatus) |
|
| 26 | |||
| 27 | /** |
||
| 28 | * @param TemplatePayload $payload |
||
| 29 | * |
||
| 30 | * @return string |
||
| 31 | */ |
||
| 32 | 1 | public function body(PayloadInterface $payload) |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @param PayloadInterface $payload |
||
| 39 | * |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | 1 | protected function render(PayloadInterface $payload) |
|
| 43 | { |
||
| 44 | 1 | $template = $this->template($payload); |
|
| 45 | 1 | $output = $this->output($payload); |
|
| 46 | |||
| 47 | 1 | return $this->environment->render($template, $output); |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param PayloadInterface $payload |
||
| 52 | * |
||
| 53 | * @return string Template name |
||
| 54 | */ |
||
| 55 | 1 | protected function template(PayloadInterface $payload) |
|
| 59 | |||
| 60 | /** |
||
| 61 | * @param PayloadInterface $payload |
||
| 62 | * |
||
| 63 | * @return array $output |
||
| 64 | */ |
||
| 65 | 1 | protected function output(PayloadInterface $payload) |
|
| 72 | } |
||
| 73 |