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 | * GET |
||
129 | *******************************************/ |
||
130 | |||
131 | /** |
||
132 | * @param $condition |
||
133 | * @return static|null |
||
134 | * @throws RecordNotFoundException |
||
135 | */ |
||
136 | public static function getOne($condition) |
||
149 | |||
150 | /** |
||
151 | * @param $condition |
||
152 | * @return static[] |
||
153 | * @throws RecordNotFoundException |
||
154 | */ |
||
155 | public static function getAll($condition) |
||
170 | |||
171 | |||
172 | /******************************************* |
||
173 | * RULES |
||
174 | *******************************************/ |
||
175 | |||
176 | /** |
||
177 | * @inheritdoc |
||
178 | */ |
||
179 | public function rules() |
||
188 | |||
189 | /******************************************* |
||
190 | * MAGIC |
||
191 | *******************************************/ |
||
192 | |||
193 | /** |
||
194 | * @param string $name |
||
195 | * @return mixed |
||
196 | */ |
||
197 | public function __get($name) |
||
208 | } |
||
209 |