1 | <?php |
||
28 | trait SourceSiteAttributeTrait |
||
29 | { |
||
30 | use ActiveRecordTrait; |
||
31 | |||
32 | /** |
||
33 | * @var SiteModel|null |
||
34 | */ |
||
35 | private $site; |
||
36 | |||
37 | /** |
||
38 | * @return array |
||
39 | */ |
||
40 | protected function sourceSiteRules(): array |
||
70 | |||
71 | /** |
||
72 | * @inheritdoc |
||
73 | */ |
||
74 | public function sourceSiteAttributes(): array |
||
80 | |||
81 | /** |
||
82 | * @inheritdoc |
||
83 | */ |
||
84 | public function sourceSiteAttributeLabels(): array |
||
90 | |||
91 | /** |
||
92 | * @param int $id |
||
93 | * @return SourceSiteAttributeTrait |
||
|
|||
94 | */ |
||
95 | public function setSiteId(int $id) |
||
99 | |||
100 | /** |
||
101 | * @return int|null |
||
102 | */ |
||
103 | public function getSiteId() |
||
107 | |||
108 | /** |
||
109 | * Associate a site |
||
110 | * |
||
111 | * @param mixed $site |
||
112 | * @return $this |
||
113 | */ |
||
114 | public function setSite($site = null) |
||
118 | |||
119 | /** |
||
120 | * @return SiteModel|null |
||
121 | */ |
||
122 | public function getSite() |
||
126 | |||
127 | /** |
||
128 | * Set associated sourceSiteId |
||
129 | * |
||
130 | * @param $id |
||
131 | * @return $this |
||
132 | */ |
||
133 | public function setSourceSiteId(int $id) |
||
138 | |||
139 | /** |
||
140 | * Get associated sourceSiteId |
||
141 | * |
||
142 | * @return int|null |
||
143 | */ |
||
144 | public function getSourceSiteId() |
||
153 | |||
154 | /** |
||
155 | * Associate a site |
||
156 | * |
||
157 | * @param mixed $site |
||
158 | * @return $this |
||
159 | */ |
||
160 | public function setSourceSite($site = null) |
||
173 | |||
174 | /** |
||
175 | * @return SiteModel|null |
||
176 | */ |
||
177 | public function getSourceSite() |
||
195 | |||
196 | /** |
||
197 | * @return SiteModel|null |
||
198 | * @throws \yii\base\InvalidArgumentException |
||
199 | */ |
||
200 | protected function resolveSite() |
||
212 | |||
213 | /** |
||
214 | * @return SiteModel|null |
||
215 | * @throws \yii\base\InvalidArgumentException |
||
216 | */ |
||
217 | private function resolveSiteFromRelation() |
||
231 | |||
232 | /** |
||
233 | * @return SiteModel|null |
||
234 | */ |
||
235 | private function resolveSiteFromId() |
||
243 | |||
244 | /** |
||
245 | * Get the associated Site |
||
246 | * |
||
247 | * @return ActiveQueryInterface |
||
248 | */ |
||
249 | public function getSiteRecord() |
||
256 | } |
||
257 |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.