| Total Complexity | 7 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Changes | 7 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 6 | trait OutputTrait |
||
| 7 | { |
||
| 8 | protected $outputCode; |
||
| 9 | protected $outputLoader; |
||
| 10 | |||
| 11 | final protected function setOutputLoader(\WebServCo\Framework\AbstractOutputLoader $outputLoader) |
||
| 12 | { |
||
| 13 | $this->outputCode = 200; // default |
||
| 14 | $this->outputLoader = $outputLoader; |
||
| 15 | } |
||
| 16 | |||
| 17 | final protected function output() |
||
| 18 | { |
||
| 19 | return $this->outputLoader; |
||
| 20 | } |
||
| 21 | |||
| 22 | final protected function outputCli($string = '', $eol = true) |
||
| 25 | } |
||
| 26 | |||
| 27 | protected function outputHtmlPartial($data, $template) |
||
| 28 | { |
||
| 29 | return new Response( |
||
| 30 | $this->output()->html($data, $template), |
||
| 31 | $this->outputCode, |
||
| 32 | ['Content-Type' => 'text/html'] |
||
| 33 | ); |
||
| 34 | } |
||
| 35 | |||
| 36 | protected function outputHtml($data, $pageTemplate, $mainTemplate = null) |
||
| 37 | { |
||
| 38 | return new Response( |
||
| 39 | $this->output()->htmlPage($data, $pageTemplate, $mainTemplate), |
||
| 40 | $this->outputCode, |
||
| 41 | ['Content-Type' => 'text/html'] |
||
| 42 | ); |
||
| 43 | } |
||
| 44 | |||
| 45 | protected function outputJson($content, $result = true) |
||
| 46 | { |
||
| 47 | $data = [ |
||
| 48 | 'result' => $result, |
||
| 49 | 'data' => $content, |
||
| 50 | ]; |
||
| 51 | return new Response( |
||
| 52 | $this->output()->json($data), |
||
| 53 | $this->outputCode, |
||
| 54 | ['Content-Type' => 'application/json'] |
||
| 55 | ); |
||
| 56 | } |
||
| 57 | |||
| 58 | protected function setOutputCode($outputCode) |
||
| 61 | } |
||
| 62 | } |
||
| 63 |