Test Setup Failed
Push — master ( 14e042...222fdb )
by Artem
07:39 queued 05:58
created

SponsorRepository::getCheckedSponsorsOfActiveEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 17
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Stfalcon\Bundle\SponsorBundle\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
use Stfalcon\Bundle\EventBundle\Entity\Event;
7
8
/**
9
 * SponsorRepository.
10
 *
11
 * This class was generated by the Doctrine ORM. Add your own custom
12
 * repository methods below.
13
 */
14
class SponsorRepository extends EntityRepository
15
{
16
    /**
17
     * Get all sponsors of event with category.
18
     *
19
     * @param Event $event
20
     *
21
     * @return array List of sponsors
22
     */
23
    public function getSponsorsOfEventWithCategory(Event $event)
24
    {
25
        $qb = $this->createQueryBuilder('s');
26
27
        $qb->select('s', 'c.id')
28
            ->where($qb->expr()->eq('e.id', ':eventId'))
29
            ->join('s.sponsorEvents', 'se')
30
            ->join('se.event', 'e')
31
            ->join('se.category', 'c')
32
            ->setParameter('eventId', $event->getId())
33
            ->orderBy('c.sortOrder', 'DESC')
34
            ->orderBy('s.sortOrder', 'DESC')
35
        ;
36
37
        return $qb->getQuery()->getResult();
38
    }
39
}
40