1 | <?php |
||
39 | abstract class ActiveRecord extends \craft\db\ActiveRecord |
||
40 | { |
||
41 | use DateCreatedRulesTrait, |
||
42 | DateUpdatedRulesTrait, |
||
43 | UidRulesTrait; |
||
44 | |||
45 | /** |
||
46 | * These attributes will have their 'getter' methods take priority over the normal attribute lookup. It's |
||
47 | * VERY important to note, that the value returned from the getter should NEVER be different than the raw |
||
48 | * attribute value set. If, for whatever reason, the getter determines the attribute value is |
||
49 | * incorrect, it should set the new value prior to returning it. |
||
50 | * |
||
51 | * These getters are commonly used to ensure an associated model and their identifier are in sync. For example, |
||
52 | * a userId attribute and a user object (with an id attribute). An operation may have saved and set an Id on the |
||
53 | * model, but the userId attribute remains null. The getter method may check (and set) the value prior to |
||
54 | * returning it. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $getterPriorityAttributes = []; |
||
59 | |||
60 | /** |
||
61 | * These attributes will have their 'setter' methods take priority over the normal attribute setting. |
||
62 | * |
||
63 | * These setters are commonly used to ensure an associated model and their identifier are in sync. For example, |
||
64 | * a userId attribute and a user object (with an id attribute). |
||
65 | * |
||
66 | * @var array |
||
67 | */ |
||
68 | protected $setterPriorityAttributes = []; |
||
69 | |||
70 | /** |
||
71 | * The table alias |
||
72 | */ |
||
73 | const TABLE_ALIAS = ''; |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | public static function tableAlias() |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public static function tableName() |
||
90 | |||
91 | |||
92 | /******************************************* |
||
93 | * OVERRIDE CONDITION HANDLING |
||
94 | *******************************************/ |
||
95 | |||
96 | /** |
||
97 | * Finds ActiveRecord instance(s) by the given condition. |
||
98 | * This method is internally called by [[findOne()]] and [[findAll()]]. |
||
99 | * @param mixed $condition please refer to [[findOne()]] for the explanation of this parameter |
||
100 | * @return ActiveQueryInterface the newly created [[ActiveQueryInterface|ActiveQuery]] instance. |
||
101 | * @throws InvalidConfigException if there is no primary key defined. |
||
102 | * @internal |
||
103 | */ |
||
104 | protected static function findByCondition($condition) |
||
136 | |||
137 | |||
138 | /******************************************* |
||
139 | * FIND |
||
140 | *******************************************/ |
||
141 | |||
142 | /** |
||
143 | * @inheritdoc |
||
144 | */ |
||
145 | public static function findOne($condition) |
||
153 | |||
154 | |||
155 | /******************************************* |
||
156 | * GET |
||
157 | *******************************************/ |
||
158 | |||
159 | /** |
||
160 | * @param $condition |
||
161 | * @return static|null |
||
162 | * @throws RecordNotFoundException |
||
163 | */ |
||
164 | public static function getOne($condition) |
||
177 | |||
178 | /** |
||
179 | * @param $condition |
||
180 | * @return static[] |
||
181 | * @throws RecordNotFoundException |
||
182 | */ |
||
183 | public static function getAll($condition) |
||
198 | |||
199 | |||
200 | /******************************************* |
||
201 | * RULES |
||
202 | *******************************************/ |
||
203 | |||
204 | /** |
||
205 | * @inheritdoc |
||
206 | */ |
||
207 | public function rules() |
||
216 | |||
217 | /******************************************* |
||
218 | * ATTRIBUTES |
||
219 | *******************************************/ |
||
220 | |||
221 | /** |
||
222 | * @param string $name |
||
223 | * @return mixed |
||
224 | */ |
||
225 | public function __get($name) |
||
233 | |||
234 | /** |
||
235 | * @param string $name |
||
236 | * @param mixed $value |
||
237 | */ |
||
238 | public function __set($name, $value) |
||
247 | |||
248 | /** |
||
249 | * @inheritdoc |
||
250 | */ |
||
251 | public function getDirtyAttributes($names = null) |
||
264 | |||
265 | /** |
||
266 | * @param $name |
||
267 | * @return bool |
||
268 | */ |
||
269 | protected function hasSetterPriority($name) |
||
274 | |||
275 | /** |
||
276 | * @param $name |
||
277 | * @return bool |
||
278 | */ |
||
279 | protected function hasGetterPriority($name) |
||
284 | } |
||
285 |