1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file was created by developers working at BitBag |
5
|
|
|
* Do you need more information about us and what we do? Visit our https://bitbag.io website! |
6
|
|
|
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
declare(strict_types=1); |
10
|
|
|
|
11
|
|
|
namespace BitBag\SyliusCmsPlugin\Repository; |
12
|
|
|
|
13
|
|
|
use BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestionInterface; |
14
|
|
|
use Doctrine\ORM\QueryBuilder; |
15
|
|
|
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; |
16
|
|
|
|
17
|
|
|
class FrequentlyAskedQuestionRepository extends EntityRepository implements FrequentlyAskedQuestionRepositoryInterface |
18
|
|
|
{ |
19
|
|
|
public function createListQueryBuilder(string $localeCode): QueryBuilder |
20
|
|
|
{ |
21
|
|
|
return $this->createQueryBuilder('o') |
22
|
|
|
->addSelect('translation') |
23
|
|
|
->leftJoin('o.translations', 'translation', 'WITH', 'translation.locale = :localeCode') |
24
|
|
|
->setParameter('localeCode', $localeCode) |
25
|
|
|
; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function findEnabledOrderedByPosition(string $localeCode, string $channelCode): array |
29
|
|
|
{ |
30
|
|
|
return $this->createQueryBuilder('o') |
|
|
|
|
31
|
|
|
->leftJoin('o.translations', 'translation') |
32
|
|
|
->innerJoin('o.channels', 'channels') |
33
|
|
|
->where('translation.locale = :localeCode') |
34
|
|
|
->andWhere('o.enabled = true') |
35
|
|
|
->andWhere('channels.code = :channelCode') |
36
|
|
|
->orderBy('o.position', 'ASC') |
37
|
|
|
->setParameter('localeCode', $localeCode) |
38
|
|
|
->setParameter('channelCode', $channelCode) |
39
|
|
|
->getQuery() |
40
|
|
|
->getResult() |
41
|
|
|
; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function findOneEnabledByCode(string $code): ?FrequentlyAskedQuestionInterface |
45
|
|
|
{ |
46
|
|
|
return $this->createQueryBuilder('o') |
|
|
|
|
47
|
|
|
->where('o.code = :code') |
48
|
|
|
->andWhere('o.enabled = true') |
49
|
|
|
->setParameter('code', $code) |
50
|
|
|
->getQuery() |
51
|
|
|
->getOneOrNullResult() |
52
|
|
|
; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|