OrderRepository::findOrders()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @author Rafał Muszyński <[email protected]>
5
 * @copyright 2015 Sourcefabric z.ú.
6
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
7
 */
8
9
namespace Newscoop\PaywallBundle\Entity\Repository;
10
11
/**
12
 * Order repository.
13
 */
14
class OrderRepository extends TranslationRepository
15
{
16
    /**
17
     * Finds all orders.
18
     */
19
    public function findOrders()
20
    {
21
        $qb = $this
22
            ->createQueryBuilder('o')
23
            ->orderBy('o.createdAt', 'DESC')
24
        ;
25
26
        return $qb
27
            ->getQuery()
28
        ;
29
    }
30
31
    public function findSingleBy($id, $locale)
32
    {
33
        $query = $this
34
            ->createQueryBuilder('o')
35
            ->select('o', 'i', 's')
36
            ->join('o.items', 'i')
37
            ->join('i.subscription', 's')
38
            ->where('o.id = :id')
39
            ->setParameter('id', $id)
40
            ->getQuery()
41
        ;
42
43
        return $this->setTranslatableHints($query, $locale)
44
            ->getSingleResult()
45
        ;
46
    }
47
48
    /**
49
     * Finds all orders by user.
50
     */
51
    public function findByUser($user)
52
    {
53
        $qb = $this
54
            ->createQueryBuilder('o')
55
            ->where('o.user = :user')
56
            ->setParameter('user', $user)
57
        ;
58
59
        return $qb
60
            ->getQuery()
61
        ;
62
    }
63
}
64