| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 16 | public function getMediaFiles() |
||
| 17 | { |
||
| 18 | $files = $this->tryDatabase(); |
||
| 19 | if (is_array($files)) { |
||
| 20 | return $files; |
||
| 21 | } |
||
| 22 | $files = $this->tryFilesystem(); |
||
| 23 | |||
| 24 | $model = $this->getCollection()->getRecord(); |
||
| 25 | |||
| 26 | foreach ($files as $file) { |
||
| 27 | MediaModels::records()->createFor( |
||
| 28 | $file, |
||
| 29 | $model, |
||
|
|
|||
| 30 | $this->getCollection() |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | $model->mediaProperties($this->getCollection())->saveDbLoaded(true); |
||
| 35 | |||
| 36 | return $files; |
||
| 37 | } |
||
| 70 |