1 | <?php |
||
22 | abstract class Behavior extends BaseBehavior |
||
23 | { |
||
24 | /** |
||
25 | * Owner name. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | public $name = ''; |
||
30 | |||
31 | /** |
||
32 | * Owner attribute names. |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | public $attributes = []; |
||
37 | |||
38 | /** |
||
39 | * Key, which is used to find model record. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | public $findModelKey = 'id'; |
||
44 | |||
45 | /** |
||
46 | * Load media model by conditions. |
||
47 | * |
||
48 | * @param array $conditions |
||
49 | * |
||
50 | * @return Mediafile|Album|ActiveRecordInterface|null |
||
51 | */ |
||
52 | abstract protected function loadModel(array $conditions); |
||
53 | |||
54 | /** |
||
55 | * Remove media model owner. |
||
56 | * |
||
57 | * @param int $ownerId |
||
58 | * @param string $owner |
||
59 | * @param string $ownerAttribute |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | abstract protected function removeOwner(int $ownerId, string $owner, string $ownerAttribute):bool; |
||
64 | |||
65 | /** |
||
66 | * @inheritdoc |
||
67 | */ |
||
68 | public function events() |
||
76 | |||
77 | /** |
||
78 | * Add owners to media model |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | public function addOwners(): void |
||
88 | |||
89 | /** |
||
90 | * Update owners of media model |
||
91 | * |
||
92 | * @return void |
||
93 | */ |
||
94 | public function updateOwners(): void |
||
101 | |||
102 | /** |
||
103 | * Delete owners of media model |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | public function deleteOwners(): void |
||
113 | |||
114 | /** |
||
115 | * Link media model with owner. |
||
116 | * |
||
117 | * @param $attributeName |
||
118 | * @param $attributeValue |
||
119 | * |
||
120 | * @return void |
||
121 | */ |
||
122 | protected function linkModelWithOwner($attributeName, $attributeValue): void |
||
138 | } |
||
139 |