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

ProductBundleRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A findByName() 0 12 1
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