Conditions | 2 |
Paths | 1 |
Total Lines | 10 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | public function init() |
||
14 | { |
||
15 | parent::init(); |
||
16 | |||
17 | $this->attributes = [ |
||
18 | $this->creatorAttribute => [ |
||
19 | ActiveRecord::EVENT_BEFORE_VALIDATE => function (ModelEvent $event, $attribute) { |
||
20 | /** @var \yii\db\ActiveRecord $model */ |
||
21 | $model = $event->sender; |
||
22 | return $model->getIsNewRecord() ? Yii::$app->getUser()->getId() : $model->$attribute; |
||
23 | }, |
||
28 |