Passed
Push — master ( 8c7b25...c84451 )
by Julito
10:55
created

LanguageRepository::findAllSubLanguages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Repository;
8
9
use Chamilo\CoreBundle\Entity\Language;
10
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
11
use Doctrine\Common\Collections\Collection;
12
use Doctrine\ORM\QueryBuilder;
13
use Doctrine\Persistence\ManagerRegistry;
14
15
class LanguageRepository extends ServiceEntityRepository
16
{
17
    public function __construct(ManagerRegistry $registry)
18
    {
19
        parent::__construct($registry, Language::class);
20
    }
21
22
    public function getAllAvailable(): QueryBuilder
23
    {
24
        $qb = $this->createQueryBuilder('l');
25
        $qb
26
            ->where(
27
                $qb->expr()->eq('l.available', true)
28
            )
29
            ->andWhere(
30
                $qb->expr()->isNull('l.parent')
31
            )
32
        ;
33
34
        return $qb;
35
    }
36
37
    /**
38
     * Get all the sub languages that are made available by the admin.
39
     *
40
     * @return Collection|Language[]
41
     */
42
    public function findAllSubLanguages()
43
    {
44
        $qb = $this->createQueryBuilder('l');
45
        $qb->select('l')
46
            ->where(
47
                $qb->expr()->eq('l.available', true)
48
            )
49
            ->andWhere(
50
                $qb->expr()->isNotNull('l.parent')
51
            )
52
        ;
53
54
        return $qb->getQuery()->getResult();
55
    }
56
}
57