Completed
Pull Request — master (#1)
by Rafał
03:36 queued 01:22
created

TenantRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findBySubdomain() 0 11 1
A findAvailableTenants() 0 9 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace SWP\MultiTenancyBundle\Repository;
15
16
use Doctrine\ORM\EntityRepository;
17
use SWP\Component\MultiTenancy\Repository\TenantRepositoryInterface;
18
19
/**
20
 * Repository interface for tenants.
21
 */
22
class TenantRepository extends EntityRepository implements TenantRepositoryInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function findBySubdomain($subdomain)
28
    {
29
        return $this
30
            ->createQueryBuilder('t')
31
            ->where('t.subdomain = :subdomain')
32
            ->andWhere('t.enabled = true')
33
            ->setParameter('subdomain', $subdomain)
34
            ->getQuery()
35
            ->getOneOrNullResult()
36
        ;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function findAvailableTenants()
43
    {
44
        return $this
45
            ->createQueryBuilder('t')
46
            ->where('t.enabled = true')
47
            ->getQuery()
48
            ->getArrayResult()
49
        ;
50
    }
51
}
52