Completed
Push — master ( 530ce9...1b2ae5 )
by Paweł
23:42 queued 20:31
created

ContainerRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getByName() 0 10 1
A getById() 0 10 1
A getHttpCacheCheckQuery() 0 9 1
A getAll() 0 6 1
1
<?php
2
3
4
/**
5
 * This file is part of the Superdesk Web Publisher Template Engine Bundle.
6
 *
7
 * Copyright 2015 Sourcefabric z.u. and contributors.
8
 *
9
 * For the full copyright and license information, please see the
10
 * AUTHORS and LICENSE files distributed with this source code.
11
 *
12
 * @copyright 2015 Sourcefabric z.ú.
13
 * @license http://www.superdesk.org/license
14
 */
15
namespace SWP\Bundle\TemplateEngineBundle\Repository;
16
17
/**
18
 * Container Repository.
19
 */
20
class ContainerRepository extends \Doctrine\ORM\EntityRepository
21
{
22
    /**
23
     * Get Query for Container searched by name.
24
     *
25
     * @param string $name
26
     *
27
     * @return \Doctrine\ORM\Query
28
     */
29
    public function getByName($name)
30
    {
31
        $qb = $this->createQueryBuilder('c')
32
            ->where('c.name = :name')
33
            ->setParameters([
34
                'name' => $name,
35
            ]);
36
37
        return $qb->getQuery();
38
    }
39
40
    /**
41
     * Get Query for Container searched by id.
42
     *
43
     * @param string $id
44
     *
45
     * @return \Doctrine\ORM\Query
46
     */
47
    public function getById($id)
48
    {
49
        $qb = $this->createQueryBuilder('c')
50
            ->where('c.id = :id')
51
            ->setParameters([
52
                'id' => $id,
53
            ]);
54
55
        return $qb->getQuery();
56
    }
57
58
    /**
59
     * Get Query for Container searched by id but only with id, createdAt and updatedAt fields.
60
     *
61
     * @param string $id
62
     *
63
     * @return \Doctrine\ORM\Query
64
     */
65
    public function getHttpCacheCheckQuery($id)
66
    {
67
        $query = $this->getEntityManager()->createQuery("select partial c.{id,createdAt,updatedAt} from SWP\TemplateEngineBundle\Model\Container c WHERE c.id = :id");
68
        $query->setParameters([
69
            'id' => $id,
70
        ]);
71
72
        return $query;
73
    }
74
75
    /**
76
     * Get Query for all Containers.
77
     *
78
     * @return \Doctrine\ORM\Query
79
     */
80
    public function getAll()
81
    {
82
        $qb = $this->createQueryBuilder('c');
83
84
        return $qb->getQuery();
85
    }
86
}
87