Total Complexity | 3 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | trait AdditionFieldsTrait |
||
15 | { |
||
16 | /** |
||
17 | * @param string $ownerName |
||
18 | * @param int $ownerId |
||
19 | * @param string $ownerAttribute |
||
20 | * @param array $paginationOptions |
||
21 | * @return array |
||
22 | */ |
||
23 | protected function getMediaFiles(string $ownerName, int $ownerId, string $ownerAttribute, array $paginationOptions = []) |
||
24 | { |
||
25 | $mediafilesQuery = OwnerMediafile::getMediaFilesQuery([ |
||
26 | 'owner' => $ownerName, |
||
27 | 'ownerId' => $ownerId, |
||
28 | 'ownerAttribute' => $ownerAttribute, |
||
29 | ]); |
||
30 | $pagination = new Pagination(array_merge([ |
||
31 | 'defaultPageSize' => Yii::$app->params['defaultPageSize'], |
||
32 | 'totalCount' => $mediafilesQuery->count() |
||
33 | ], $paginationOptions) |
||
34 | ); |
||
35 | |||
36 | return [ |
||
37 | 'items' => $mediafilesQuery->offset($pagination->offset) |
||
38 | ->limit($pagination->limit) |
||
39 | ->all(), |
||
40 | 'pagination' => $pagination |
||
41 | ]; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param string|null $type |
||
46 | * @return array|\yii\db\ActiveRecord[] |
||
47 | */ |
||
48 | protected function getAlbums(string $type = null) |
||
59 | } |
||
60 | } |
||
61 |