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