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\SyliusElasticsearchPlugin\QueryBuilder; |
||
12 | |||
13 | use Elastica\Query\AbstractQuery; |
||
14 | use Elastica\Query\Terms; |
||
15 | use Sylius\Component\Channel\Context\ChannelContextInterface; |
||
16 | |||
17 | final class HasChannelQueryBuilder implements QueryBuilderInterface |
||
18 | { |
||
19 | /** @var ChannelContextInterface */ |
||
20 | private $channelContext; |
||
21 | |||
22 | /** @var string */ |
||
23 | private $channelsProperty; |
||
24 | |||
25 | public function __construct(ChannelContextInterface $channelContext, string $channelsProperty) |
||
26 | { |
||
27 | $this->channelContext = $channelContext; |
||
28 | $this->channelsProperty = $channelsProperty; |
||
29 | } |
||
30 | |||
31 | public function buildQuery(array $data): ?AbstractQuery |
||
32 | { |
||
33 | $channelQuery = new Terms($this->channelsProperty); |
||
34 | $channelQuery->setTerms([strtolower($this->channelContext->getChannel()->getCode())]); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
35 | |||
36 | return $channelQuery; |
||
37 | } |
||
38 | } |
||
39 |