carono /
yii2-1c-exchange
| 1 | <?php |
||
| 2 | |||
| 3 | |||
| 4 | namespace carono\exchange1c\controllers; |
||
| 5 | |||
| 6 | |||
| 7 | use Symfony\Component\Filesystem\Exception\FileNotFoundException; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use yii\helpers\FileHelper; |
||
| 9 | |||
| 10 | class FileController extends Controller |
||
| 11 | { |
||
| 12 | protected static function getAlias($path) |
||
| 13 | { |
||
| 14 | return \Yii::getAlias("@vendor/carono/yii2-1c-exchange/" . ltrim($path, '/')); |
||
| 15 | } |
||
| 16 | |||
| 17 | protected function out($file, $options = []) |
||
| 18 | { |
||
| 19 | $filename = self::getAlias($file); |
||
| 20 | if (!file_exists($filename)) { |
||
| 21 | throw new FileNotFoundException($filename); |
||
| 22 | } |
||
| 23 | $content = file_get_contents($filename); |
||
| 24 | return \Yii::$app->response->sendContentAsFile($content, basename($filename), $options); |
||
| 25 | } |
||
| 26 | |||
| 27 | protected function outAsFile($file) |
||
| 28 | { |
||
| 29 | return $this->out($file); |
||
| 30 | } |
||
| 31 | |||
| 32 | protected function outAsImage($file) |
||
| 33 | { |
||
| 34 | $options = [ |
||
| 35 | 'inline' => true, |
||
| 36 | 'mimeType' => FileHelper::getMimeType(self::getAlias($file)) |
||
| 37 | ]; |
||
| 38 | return $this->out($file, $options); |
||
| 39 | } |
||
| 40 | |||
| 41 | public function actionArticle($file) |
||
| 42 | { |
||
| 43 | return $this->outAsImage("files/articles/$file"); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function actionDoc($file) |
||
| 47 | { |
||
| 48 | return $this->outAsImage("/files/doc/$file"); |
||
| 49 | } |
||
| 50 | |||
| 51 | public function actionXml($file) |
||
| 52 | { |
||
| 53 | return $this->outAsImage("/files/xml/$file"); |
||
| 54 | } |
||
| 55 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths