Total Complexity | 11 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Coverage | 94.74% |
Changes | 0 |
1 | <?php |
||
8 | trait MultiTenantRecord |
||
9 | { |
||
10 | /** |
||
11 | *@inheritdoc |
||
12 | */ |
||
13 | 1 | public function beforeSave($insert) |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 3 | public static function find() |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | 1 | protected function resolveFields(array $fields, array $expand) |
|
41 | { |
||
42 | 1 | $fields = parent::resolveFields($fields, $expand); |
|
43 | |||
44 | 1 | if ($this->hasAttribute(TenantInterface::ATTRIBUTE_NAME)) { |
|
|
|||
45 | 1 | unset($fields[TenantInterface::ATTRIBUTE_NAME]); |
|
46 | } |
||
47 | |||
48 | 1 | return $fields; |
|
49 | } |
||
50 | |||
51 | |||
52 | |||
53 | /** |
||
54 | * This method is invoked before assign the attribute tenant id |
||
55 | * You may override this method to do preliminary checks before apply tenant id. |
||
56 | * @return boolean whether the tenant id should be assigned. Defaults to true. |
||
57 | */ |
||
58 | 1 | protected function beforeApplyTenant() |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * This method is invoked after assign the attribute tenant id |
||
65 | * You may override this method to do postprocessing after apply tenant id. |
||
66 | */ |
||
67 | 1 | protected function afterApplyTenant() |
|
72 |