Passed
Push — master ( 76abd2...ab5d59 )
by Julito
10:01
created

LanguageRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findAllPlatformSubLanguages() 0 12 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Repository;
5
6
use Chamilo\CoreBundle\Entity\Language;
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Doctrine\Common\Persistence\ManagerRegistry;
9
10
/**
11
 * Class LanguageRepository.
12
 *
13
 * @package Chamilo\CoreBundle\Repository
14
 */
15
class LanguageRepository extends ServiceEntityRepository
16
{
17
    /**
18
     * LanguageRepository constructor.
19
     *
20
     * @param ManagerRegistry $registry
21
     */
22
    public function __construct(ManagerRegistry $registry)
23
    {
24
        parent::__construct($registry, Language::class);
25
    }
26
27
    /**
28
     * Get all the sub languages that are made available by the admin.
29
     *
30
     * @return array
31
     */
32
    public function findAllPlatformSubLanguages()
33
    {
34
        $qb = $this->createQueryBuilder('l');
35
        $qb->select('l')
36
            ->where(
37
                $qb->expr()->eq('l.available', true)
38
            )
39
            ->andWhere(
40
                $qb->expr()->isNotNull('l.parent')
41
            );
42
43
        return $qb->getQuery()->getResult();
44
    }
45
}
46