TenantAwareFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A addFilterConstraint() 0 14 2
1
<?php
2
3
4
namespace Tahoe\Bundle\MultiTenancyBundle\Query\Filter\SQLFilter;
5
6
use Doctrine\ORM\Mapping\ClassMetaData,
7
    Doctrine\ORM\Query\Filter\SQLFilter;
8
9
class TenantAwareFilter extends SQLFilter
10
{
11
    public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
12
    {
13
        if (!$targetEntity->reflClass->implementsInterface('Tahoe\Bundle\MultiTenancyBundle\Model\TenantAwareInterface')) {
14
            return "";
15
        }
16
17
        // it would be easier (and probably less hackish) if I just wrote $column = "tenant_id"
18
        //$column = $targetEntity
19
        //    ->getAssociationsByTargetClass('Tahoe\Bundle\MultiTenancyBundle\Model\MultiTenantTenantInterface')
20
        //['tenant']['targetToSourceKeyColumns']['id'];
21
        $column = 'tenant_id';
22
23
        return $targetTableAlias . '.' . $column . ' = ' . $this->getParameter('tenantId');
24
    }
25
}
26