| Conditions | 4 |
| Paths | 3 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 45 | public function upload($fileInstance) |
||
| 46 | { |
||
| 47 | if ($fileInstance === null) { |
||
| 48 | return false; |
||
| 49 | } |
||
| 50 | |||
| 51 | $this->background = $fileInstance; |
||
| 52 | $name = $this->background->baseName.'.'.$this->background->extension; |
||
| 53 | $filepath = Media::BASE_PATH.self::PATH.$name; |
||
| 54 | if ($this->validate() && $this->background->saveAs($filepath)) { |
||
| 55 | $model = new TemplateBackground(); |
||
| 56 | $model->webpath = Media::BASE_URI.$filepath; |
||
| 57 | |||
| 58 | return $model->save(); |
||
| 59 | } |
||
| 60 | |||
| 61 | return false; |
||
| 62 | } |
||
| 63 | } |
||
| 64 |