Completed
Pull Request — master (#34)
by
unknown
05:48
created

ProductBundleRepository::findByName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Created by solutionDrive GmbH
7
 *
8
 * @copyright 2018 solutionDrive GmbH
9
 */
10
11
namespace solutionDrive\SyliusProductBundlesPlugin\Repository;
12
13
use solutionDrive\SyliusProductBundlesPlugin\Entity\ProductBundleInterface;
14
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
15
16
class ProductBundleRepository extends EntityRepository implements ProductBundleRepositoryInterface
17
{
18
    /**
19
     * @param string $name
20
     * @param string $locale
21
     *
22
     * @return array|ProductBundleInterface[]
23
     */
24
    public function findByName(string $name, string $locale): array
25
    {
26
        return $this->createQueryBuilder('b')
27
            ->innerJoin('b.product', 'o')
28
            ->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
29
            ->andWhere('translation.name = :name')
30
            ->setParameter('name', $name)
31
            ->setParameter('locale', $locale)
32
            ->getQuery()
33
            ->getResult()
34
            ;
35
    }
36
}
37