Total Complexity | 3 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class FileStream extends Action |
||
15 | { |
||
16 | /** |
||
17 | * @var string GET parameter to decide if force the download or show it on |
||
18 | * the browser. |
||
19 | */ |
||
20 | public $downloadParam = 'download'; |
||
21 | |||
22 | /** |
||
23 | * @inheritdoc |
||
24 | */ |
||
25 | public function init() |
||
26 | { |
||
27 | parent::init(); |
||
28 | $interfaces = class_implements($this->modelClass); |
||
29 | if (empty($interfaces[FileRecord::class])) { |
||
30 | throw new InvalidConfigException( |
||
31 | "The class `{$this->modelClass}` must implement " |
||
32 | . FileRecord::class |
||
33 | ); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Shows the file on the browser or download it after checking access. |
||
39 | * |
||
40 | * @param mixed $id the identifier value. |
||
41 | * @param string $ext the requested file extension. |
||
42 | */ |
||
43 | public function run($id, string $ext) |
||
57 | ] |
||
58 | ); |
||
61 |