1 | <?php |
||
24 | class TimestampBehavior extends Behavior |
||
25 | { |
||
26 | /** |
||
27 | * @var array An array with all fields where the timestamp should be applied to on insert. |
||
28 | */ |
||
29 | public $insert = []; |
||
30 | |||
31 | /** |
||
32 | * @var array An array with all fields where the timestamp should be applied to on update. |
||
33 | */ |
||
34 | public $update = []; |
||
35 | |||
36 | /** |
||
37 | * Register event handlers before insert and update. |
||
38 | * |
||
39 | * @see \yii\base\Behavior::events() |
||
40 | */ |
||
41 | public function events() |
||
48 | |||
49 | /** |
||
50 | * Insert the timestamp for all provided fields. |
||
51 | * |
||
52 | * @param \yii\base\Event $event Event object from Active Record. |
||
53 | */ |
||
54 | public function beforeInsert($event) |
||
60 | |||
61 | /** |
||
62 | * Update the timestamp for all provided fields. |
||
63 | * |
||
64 | * @param \yii\base\Event $event Event object from Active Record. |
||
65 | */ |
||
66 | public function beforeUpdate($event) |
||
72 | } |
||
73 |