1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* another great project. |
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
8
|
|
|
* an email on [email protected]. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace BitBag\SyliusCmsPlugin\Repository; |
14
|
|
|
|
15
|
|
|
use BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestionInterface; |
16
|
|
|
use Doctrine\ORM\QueryBuilder; |
17
|
|
|
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; |
18
|
|
|
|
19
|
|
|
final class FrequentlyAskedQuestionRepository extends EntityRepository implements FrequentlyAskedQuestionRepositoryInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* {@inheritdoc} |
23
|
|
|
*/ |
24
|
|
|
public function createListQueryBuilder(string $locale): QueryBuilder |
25
|
|
|
{ |
26
|
|
|
return $this->createQueryBuilder('o') |
27
|
|
|
->innerJoin('o.translations', 'translation') |
28
|
|
|
->where('translation.locale = :locale') |
29
|
|
|
->setParameter('locale', $locale) |
30
|
|
|
; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public function findEnabledOrderedByPositionAndChannelCode(string $localeCode, string $channelCode): array |
37
|
|
|
{ |
38
|
|
|
return $this->createQueryBuilder('o') |
39
|
|
|
->leftJoin('o.translations', 'translation') |
40
|
|
|
->innerJoin('o.channels', 'channels') |
41
|
|
|
->where('translation.locale = :localeCode') |
42
|
|
|
->andWhere('o.enabled = true') |
43
|
|
|
->andWhere('channels.code = :channelCode') |
44
|
|
|
->orderBy('o.position', 'ASC') |
45
|
|
|
->setParameter('localeCode', $localeCode) |
46
|
|
|
->setParameter('channelCode', $channelCode) |
47
|
|
|
->getQuery() |
48
|
|
|
->getResult() |
49
|
|
|
; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
|
|
public function findOneEnabledByCode(string $code): ?FrequentlyAskedQuestionInterface |
56
|
|
|
{ |
57
|
|
|
return $this->createQueryBuilder('o') |
58
|
|
|
->where('o.code = :code') |
59
|
|
|
->andWhere('o.enabled = true') |
60
|
|
|
->setParameter('code', $code) |
61
|
|
|
->getQuery() |
62
|
|
|
->getOneOrNullResult() |
63
|
|
|
; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|