| Total Complexity | 6 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 77.78% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class MultiTenantQuery extends ActiveQuery |
||
| 10 | { |
||
| 11 | private $_withTenant = true; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * {@inheritDoc} |
||
| 15 | */ |
||
| 16 | 3 | public function prepare($builder) |
|
| 17 | { |
||
| 18 | 3 | if ($this->_withTenant) { |
|
| 19 | 3 | $this->addTenantCondition(); |
|
| 20 | 3 | } |
|
| 21 | 3 | return parent::prepare($builder); |
|
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Disables where tenant condition |
||
| 26 | * @return $this |
||
| 27 | */ |
||
| 28 | 3 | public function withoutTenant() |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Enables where tenant condition |
||
| 36 | * @return $this |
||
| 37 | */ |
||
| 38 | public function withTenant() |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Adds an additional WHERE tenant condition to the existing one. |
||
| 46 | * @return void |
||
| 47 | */ |
||
| 48 | 3 | private function addTenantCondition() |
|
| 58 | } |