|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Itstructure\MFUploader\models; |
|
4
|
|
|
|
|
5
|
|
|
use yii\db\ActiveQuery; |
|
6
|
|
|
use yii\base\InvalidArgumentException; |
|
|
|
|
|
|
7
|
|
|
use yii\helpers\ArrayHelper; |
|
8
|
|
|
use Itstructure\MFUploader\models\album\Album; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* This is the model class for table "owners_albums". |
|
12
|
|
|
* |
|
13
|
|
|
* @property int $albumId Album id. |
|
14
|
|
|
* @property Album $album |
|
15
|
|
|
* |
|
16
|
|
|
* @package Itstructure\MFUploader\models |
|
17
|
|
|
* |
|
18
|
|
|
* @author Andrey Girnik <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class OwnerAlbum extends Owner |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* {@inheritdoc} |
|
24
|
|
|
*/ |
|
25
|
|
|
public static function tableName() |
|
26
|
|
|
{ |
|
27
|
|
|
return 'owners_albums'; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritdoc} |
|
32
|
|
|
*/ |
|
33
|
|
|
public function rules() |
|
34
|
|
|
{ |
|
35
|
|
|
return ArrayHelper::merge(parent::rules(), [ |
|
36
|
|
|
[ |
|
37
|
|
|
'albumId', |
|
38
|
|
|
'required', |
|
39
|
|
|
], |
|
40
|
|
|
[ |
|
41
|
|
|
'albumId', |
|
42
|
|
|
'integer', |
|
43
|
|
|
], |
|
44
|
|
|
[ |
|
45
|
|
|
[ |
|
46
|
|
|
'albumId', |
|
47
|
|
|
'ownerId', |
|
48
|
|
|
'owner', |
|
49
|
|
|
'ownerAttribute', |
|
50
|
|
|
], |
|
51
|
|
|
'unique', |
|
52
|
|
|
'targetAttribute' => [ |
|
53
|
|
|
'albumId', |
|
54
|
|
|
'ownerId', |
|
55
|
|
|
'owner', |
|
56
|
|
|
'ownerAttribute', |
|
57
|
|
|
], |
|
58
|
|
|
], |
|
59
|
|
|
[ |
|
60
|
|
|
['albumId'], |
|
61
|
|
|
'exist', |
|
62
|
|
|
'skipOnError' => true, |
|
63
|
|
|
'targetClass' => Album::class, |
|
64
|
|
|
'targetAttribute' => ['albumId' => 'id'], |
|
65
|
|
|
], |
|
66
|
|
|
]); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* {@inheritdoc} |
|
71
|
|
|
*/ |
|
72
|
|
|
public function attributeLabels() |
|
73
|
|
|
{ |
|
74
|
|
|
return ArrayHelper::merge(parent::attributeLabels(), [ |
|
75
|
|
|
'albumId' => 'Album ID', |
|
76
|
|
|
]); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return \yii\db\ActiveQuery |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getAlbum() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->hasOne(Album::class, ['id' => 'albumId']); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Get all albums by owner. |
|
89
|
|
|
* |
|
90
|
|
|
* @param string $owner |
|
91
|
|
|
* @param int $ownerId |
|
92
|
|
|
* @param string $ownerAttribute |
|
93
|
|
|
* |
|
94
|
|
|
* @return Album[] |
|
95
|
|
|
*/ |
|
96
|
|
|
public static function getAlbums(string $owner, int $ownerId, string $ownerAttribute = null) |
|
97
|
|
|
{ |
|
98
|
|
|
return static::getAlbumsQuery(static::buildFilterOptions($ownerId, $owner, $ownerAttribute))->all(); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Get all albums Query by owner. |
|
103
|
|
|
* |
|
104
|
|
|
* @param array $args. It can be an array of the next params: owner{string}, ownerId{int}, ownerAttribute{string}. |
|
105
|
|
|
* |
|
106
|
|
|
* @return ActiveQuery |
|
107
|
|
|
*/ |
|
108
|
|
|
public static function getAlbumsQuery(array $args = []): ActiveQuery |
|
109
|
|
|
{ |
|
110
|
|
|
return Album::find() |
|
111
|
|
|
->where([ |
|
112
|
|
|
'id' => self::getEntityIdsQuery('albumId', $args)->asArray() |
|
113
|
|
|
]); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Get image albums by owner. |
|
118
|
|
|
* |
|
119
|
|
|
* @param string $owner |
|
120
|
|
|
* @param int $ownerId |
|
121
|
|
|
* |
|
122
|
|
|
* @return Album[] |
|
123
|
|
|
*/ |
|
124
|
|
|
public static function getImageAlbums(string $owner, int $ownerId) |
|
125
|
|
|
{ |
|
126
|
|
|
return static::getAlbums($owner, $ownerId, Album::ALBUM_TYPE_IMAGE); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Get audio albums by owner. |
|
131
|
|
|
* |
|
132
|
|
|
* @param string $owner |
|
133
|
|
|
* @param int $ownerId |
|
134
|
|
|
* |
|
135
|
|
|
* @return Album[] |
|
136
|
|
|
*/ |
|
137
|
|
|
public static function getAudioAlbums(string $owner, int $ownerId) |
|
138
|
|
|
{ |
|
139
|
|
|
return static::getAlbums($owner, $ownerId, Album::ALBUM_TYPE_AUDIO); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Get video albums by owner. |
|
144
|
|
|
* |
|
145
|
|
|
* @param string $owner |
|
146
|
|
|
* @param int $ownerId |
|
147
|
|
|
* |
|
148
|
|
|
* @return Album[] |
|
149
|
|
|
*/ |
|
150
|
|
|
public static function getVideoAlbums(string $owner, int $ownerId) |
|
151
|
|
|
{ |
|
152
|
|
|
return static::getAlbums($owner, $ownerId, Album::ALBUM_TYPE_VIDEO); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Get application albums by owner. |
|
157
|
|
|
* |
|
158
|
|
|
* @param string $owner |
|
159
|
|
|
* @param int $ownerId |
|
160
|
|
|
* |
|
161
|
|
|
* @return Album[] |
|
162
|
|
|
*/ |
|
163
|
|
|
public static function getAppAlbums(string $owner, int $ownerId) |
|
164
|
|
|
{ |
|
165
|
|
|
return static::getAlbums($owner, $ownerId, Album::ALBUM_TYPE_APP); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Get text albums by owner. |
|
170
|
|
|
* |
|
171
|
|
|
* @param string $owner |
|
172
|
|
|
* @param int $ownerId |
|
173
|
|
|
* |
|
174
|
|
|
* @return Album[] |
|
175
|
|
|
*/ |
|
176
|
|
|
public static function getTextAlbums(string $owner, int $ownerId) |
|
177
|
|
|
{ |
|
178
|
|
|
return static::getAlbums($owner, $ownerId, Album::ALBUM_TYPE_TEXT); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Get other albums by owner. |
|
183
|
|
|
* |
|
184
|
|
|
* @param string $owner |
|
185
|
|
|
* @param int $ownerId |
|
186
|
|
|
* |
|
187
|
|
|
* @return Album[] |
|
188
|
|
|
*/ |
|
189
|
|
|
public static function getOtherAlbums(string $owner, int $ownerId) |
|
190
|
|
|
{ |
|
191
|
|
|
return static::getAlbums($owner, $ownerId, Album::ALBUM_TYPE_OTHER); |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* Get model album primary key name. |
|
196
|
|
|
* |
|
197
|
|
|
* @return string |
|
198
|
|
|
*/ |
|
199
|
|
|
protected static function getModelKeyName(): string |
|
200
|
|
|
{ |
|
201
|
|
|
return 'albumId'; |
|
202
|
|
|
} |
|
203
|
|
|
} |
|
204
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths