Completed
Push — master ( 4201d9...0a29a7 )
by Paweł
19s queued 10s
created

AttachmentRepository::getAllForCourse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\Attachment;
6
use App\Model\CourseInterface;
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Symfony\Bridge\Doctrine\RegistryInterface;
9
10
/**
11
 * @method Attachment|null find($id, $lockMode = null, $lockVersion = null)
12
 * @method Attachment|null findOneBy(array $criteria, array $orderBy = null)
13
 * @method Attachment[]    findAll()
14
 * @method Attachment[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
15
 */
16
class AttachmentRepository extends ServiceEntityRepository implements AttachmentRepositoryInterface
17
{
18
    public function __construct(RegistryInterface $registry)
19
    {
20
        parent::__construct($registry, Attachment::class);
21
    }
22
23
    public function getAllForCourse(CourseInterface $course): array
24
    {
25
        return $this->createQueryBuilder('a')
26
            ->leftJoin('a.lesson', 'l')
27
            ->leftJoin('l.module', 'm')
28
            ->where('m.course = :course')
29
            ->setParameter('course', $course)
30
            ->orderBy('a.name')
31
            ->getQuery()
32
            ->getResult()
33
            ;
34
    }
35
}
36