Completed
Push — product-create-admin ( 72e5ba )
by Kamil
23:08
created

ShipmentRepository::createListQueryBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
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\ResourceBundle\Doctrine\ORM\EntityRepository;
15
use Sylius\Component\Core\Repository\ShipmentRepositoryInterface;
16
17
class ShipmentRepository extends EntityRepository implements ShipmentRepositoryInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function createListQueryBuilder()
23
    {
24
        return $this->createQueryBuilder('o');
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function findOneByOrderId($shipmentId, $orderId)
31
    {
32
        return $this->createQueryBuilder('o')
33
            ->andWhere('o.id = :shipmentId')
34
            ->andWhere('o.order = :orderId')
35
            ->setParameter('shipmentId', $shipmentId)
36
            ->setParameter('orderId', $orderId)
37
            ->getQuery()
38
            ->getOneOrNullResult()
39
        ;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function findByName($name, $locale)
46
    {
47
        return $this->createQueryBuilder('o')
48
            ->innerJoin('o.translations', 'translation')
49
            ->andWhere('translation.name = :name')
50
            ->andWhere('translation.locale = :locale')
51
            ->setParameter('name', $name)
52
            ->setParameter('localeCode', $locale)
53
            ->getQuery()
54
            ->getResult()
55
        ;
56
    }
57
}
58