Conditions | 6 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 6.0493 |
Changes | 0 |
1 | <?php |
||
13 | 1 | public function beforeSave($insert) |
|
14 | { |
||
15 | 1 | if (!Yii::$app->user->isGuest) { |
|
16 | 1 | $identity = Yii::$app->user->identity; |
|
17 | 1 | if ($identity instanceof TenantInterface) { |
|
18 | 1 | if ($insert && $this->beforeApplyTenant() && !$this->tenant_id) { |
|
19 | 1 | $this->tenant_id = $identity->getTenantId(); |
|
|
|||
20 | 1 | $this->afterApplyTenant(); |
|
21 | } |
||
22 | } else { |
||
23 | throw new NotSupportedException("Identity does not implements TenantInteface"); |
||
24 | } |
||
25 | } |
||
26 | 1 | return parent::beforeSave($insert); |
|
27 | } |
||
57 |