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

ExtraFieldOptionsRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findSecondaryOptions() 0 15 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Repository;
5
6
use Chamilo\CoreBundle\Entity\ExtraFieldOptions;
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Doctrine\Common\Persistence\ManagerRegistry;
9
10
/**
11
 * Class ExtraFieldOptionsRepository.
12
 *
13
 * @package Chamilo\CoreBundle\Repository
14
 */
15
class ExtraFieldOptionsRepository extends ServiceEntityRepository
16
{
17
    /**
18
     * ExtraFieldOptionsRepository constructor.
19
     *
20
     * @param ManagerRegistry $registry
21
     */
22
    public function __construct(ManagerRegistry $registry)
23
    {
24
        parent::__construct($registry, ExtraFieldOptions::class);
25
    }
26
27
    /**
28
     * Get the secondary options. For double select extra field.
29
     *
30
     * @param ExtraFieldOptions $option
31
     *
32
     * @return array
33
     */
34
    public function findSecondaryOptions(ExtraFieldOptions $option)
35
    {
36
        $qb = $this->createQueryBuilder('so');
37
        $qb
38
            ->where(
39
                $qb->expr()->eq('so.field', $option->getField()->getId())
40
            )
41
            ->andWhere(
42
                $qb->expr()->eq('so.value', $option->getId())
43
            )
44
            ->orderBy('so.displayText', 'ASC');
45
46
        return $qb
47
            ->getQuery()
48
            ->getResult();
49
    }
50
}
51