| Conditions | 5 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public function afterSave() |
||
| 28 | { |
||
| 29 | /** @var \yii\db\BaseActiveRecord $model */ |
||
| 30 | $model = $this->owner; |
||
| 31 | if (in_array($model->scenario, $this->scenarios)) { |
||
| 32 | if ($this->getUploadedFile() instanceof UploadedFile) { |
||
| 33 | $path = $this->getUploadPath($this->attribute); |
||
| 34 | if (is_string($path) && FileHelper::createDirectory(dirname($path))) { |
||
| 35 | $this->save($this->getUploadedFile(), $path); |
||
| 36 | $this->afterUpload(); |
||
| 37 | } else { |
||
| 38 | throw new InvalidParamException("Directory specified in 'path' attribute doesn't exist or cannot be created."); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 | } |
||
| 43 | } |
||
| 44 |