Completed
Push — master ( 7f4b5a...549eec )
by Michał
47:24 queued 31:36
created

PaymentMethodRepository::createListQueryBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\CoreBundle\Doctrine\ORM;
13
14
use Sylius\Bundle\PaymentBundle\Doctrine\ORM\PaymentMethodRepository as BasePaymentMethodRepository;
15
16
class PaymentMethodRepository extends BasePaymentMethodRepository
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function createListQueryBuilder()
22
    {
23
        return $this
24
            ->createQueryBuilder('o')
25
            ->addSelect('translation')
26
            ->leftJoin('o.translations', 'translation')
27
        ;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function getQueryBuilderForChoiceType(array $options)
34
    {
35
        $queryBuilder = parent::getQueryBuilderForChoiceType($options);
36
37
        if ($options['channel']) {
38
            $queryBuilder->andWhere('o IN (:methods)')
39
                ->setParameter('methods', $options['channel']->getPaymentMethods()->toArray());
40
        }
41
42
        return $queryBuilder;
43
    }
44
}
45