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 | * The table alias |
||
62 | */ |
||
63 | const TABLE_ALIAS = ''; |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | public static function tableAlias() |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public static function tableName() |
||
80 | |||
81 | |||
82 | /******************************************* |
||
83 | * OVERRIDE CONDITION HANDLING |
||
84 | *******************************************/ |
||
85 | |||
86 | /** |
||
87 | * Finds ActiveRecord instance(s) by the given condition. |
||
88 | * This method is internally called by [[findOne()]] and [[findAll()]]. |
||
89 | * @param mixed $condition please refer to [[findOne()]] for the explanation of this parameter |
||
90 | * @return ActiveQueryInterface the newly created [[ActiveQueryInterface|ActiveQuery]] instance. |
||
91 | * @throws InvalidConfigException if there is no primary key defined. |
||
92 | * @internal |
||
93 | */ |
||
94 | protected static function findByCondition($condition) |
||
126 | |||
127 | |||
128 | /******************************************* |
||
129 | * FIND |
||
130 | *******************************************/ |
||
131 | |||
132 | /** |
||
133 | * @inheritdoc |
||
134 | */ |
||
135 | public static function findOne($condition) |
||
143 | |||
144 | |||
145 | /******************************************* |
||
146 | * GET |
||
147 | *******************************************/ |
||
148 | |||
149 | /** |
||
150 | * @param $condition |
||
151 | * @return static|null |
||
152 | * @throws RecordNotFoundException |
||
153 | */ |
||
154 | public static function getOne($condition) |
||
167 | |||
168 | /** |
||
169 | * @param $condition |
||
170 | * @return static[] |
||
171 | * @throws RecordNotFoundException |
||
172 | */ |
||
173 | public static function getAll($condition) |
||
188 | |||
189 | |||
190 | /******************************************* |
||
191 | * RULES |
||
192 | *******************************************/ |
||
193 | |||
194 | /** |
||
195 | * @inheritdoc |
||
196 | */ |
||
197 | public function rules() |
||
206 | |||
207 | /******************************************* |
||
208 | * MAGIC |
||
209 | *******************************************/ |
||
210 | |||
211 | /** |
||
212 | * @param string $name |
||
213 | * @return mixed |
||
214 | */ |
||
215 | public function __get($name) |
||
226 | } |
||
227 |