|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file was created by the 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\PageInterface; |
|
16
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
17
|
|
|
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @author Patryk Drapik <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class PageRepository extends EntityRepository implements PageRepositoryInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
*/ |
|
27
|
|
|
public function createListQueryBuilder(string $locale): QueryBuilder |
|
28
|
|
|
{ |
|
29
|
|
|
return $this->createQueryBuilder('o') |
|
30
|
|
|
->innerJoin('o.translations', 'translation') |
|
31
|
|
|
->where('translation.locale = :locale') |
|
32
|
|
|
->setParameter('locale', $locale) |
|
33
|
|
|
; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* {@inheritdoc} |
|
38
|
|
|
*/ |
|
39
|
|
|
public function findOneEnabledByCode(string $code, ?string $localeCode): ?PageInterface |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->createQueryBuilder('o') |
|
42
|
|
|
->leftJoin('o.translations', 'translation') |
|
43
|
|
|
->where('translation.locale = :localeCode') |
|
44
|
|
|
->andWhere('o.code = :code') |
|
45
|
|
|
->andWhere('o.enabled = true') |
|
46
|
|
|
->setParameter('code', $code) |
|
47
|
|
|
->setParameter('localeCode', $localeCode) |
|
48
|
|
|
->getQuery() |
|
49
|
|
|
->getOneOrNullResult() |
|
50
|
|
|
; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* {@inheritdoc} |
|
55
|
|
|
*/ |
|
56
|
|
|
public function findOneEnabledBySlug(string $slug, ?string $localeCode): ?PageInterface |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->createQueryBuilder('o') |
|
59
|
|
|
->leftJoin('o.translations', 'translation') |
|
60
|
|
|
->where('translation.locale = :localeCode') |
|
61
|
|
|
->andWhere('translation.slug = :slug') |
|
62
|
|
|
->andWhere('o.enabled = true') |
|
63
|
|
|
->setParameter('localeCode', $localeCode) |
|
64
|
|
|
->setParameter('slug', $slug) |
|
65
|
|
|
->getQuery() |
|
66
|
|
|
->getOneOrNullResult() |
|
67
|
|
|
; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* {@inheritdoc} |
|
72
|
|
|
*/ |
|
73
|
|
|
public function createShopListQueryBuilder(string $sectionCode): QueryBuilder |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->createQueryBuilder('o') |
|
76
|
|
|
->innerJoin('o.sections', 'section') |
|
77
|
|
|
->where('section.code = :sectionCode') |
|
78
|
|
|
->andWhere('o.enabled = true') |
|
79
|
|
|
->setParameter('sectionCode', $sectionCode) |
|
80
|
|
|
; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|