Completed
Push — master ( 68f942...d69058 )
by Rafał
18:18
created

OrganizationRepository::findOneByName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. 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 2016 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace SWP\Bundle\MultiTenancyBundle\Doctrine\ORM;
15
16
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository;
17
use SWP\Component\MultiTenancy\Repository\OrganizationRepositoryInterface;
18
19
class OrganizationRepository extends EntityRepository implements OrganizationRepositoryInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function findOneByName($name)
25
    {
26
        return $this
27
            ->createQueryBuilder('o')
28
            ->where('o.name = :name')
29
            ->setParameter('name', $name)
30
            ->getQuery()
31
            ->getOneOrNullResult();
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function findOneByCode($code)
38
    {
39
        return $this
40
            ->createQueryBuilder('o')
41
            ->where('o.code = :code')
42
            ->setParameter('code', $code)
43
            ->getQuery()
44
            ->getOneOrNullResult();
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function findAvailable()
51
    {
52
        return $this
53
            ->createQueryBuilder('o')
54
            ->where('o.enabled = true')
55
            ->getQuery()
56
            ->getArrayResult();
57
    }
58
}
59