Total Complexity | 8 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
11 | class Database extends AbstractLoader |
||
12 | { |
||
13 | /** |
||
14 | * @return File[] |
||
15 | */ |
||
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 | } |
||
38 | |||
39 | /** |
||
40 | * @return array|false |
||
41 | */ |
||
42 | protected function tryDatabase() |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return array|false |
||
63 | */ |
||
64 | protected function tryFilesystem() |
||
70 |