| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function render(array $params = []) |
||
| 19 | { |
||
| 20 | $fullPath = Module::getInstance()->getLocalPath($this->path); |
||
| 21 | $mimeType = mime_content_type($fullPath); |
||
| 22 | |||
| 23 | if ($mimeType === 'text/plain') { |
||
| 24 | $text = Module::getInstance()->getStorage()->read($this->path); |
||
| 25 | return "<pre>$text</pre>"; |
||
| 26 | } |
||
| 27 | |||
| 28 | $response = Yii::$app->response; |
||
| 29 | $response->format = $response::FORMAT_RAW; |
||
| 30 | $response->headers->set('Content-Type', $mimeType); |
||
| 31 | readfile($fullPath); |
||
| 32 | Yii::$app->end(); |
||
| 33 | } |
||
| 34 | |||
| 40 |