From a82f7e127e204615b24a4648975314d431d7bb34 Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Tue, 9 Jul 2024 10:58:54 +0200 Subject: [PATCH] op-352 - Restore form query builders to check behat tests --- .../FormQueryBuilder/SiteWideFacetsQueryBuilder.php | 11 +++-------- .../FormQueryBuilder/TaxonFacetsQueryBuilder.php | 3 +-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/QueryBuilder/FormQueryBuilder/SiteWideFacetsQueryBuilder.php b/src/QueryBuilder/FormQueryBuilder/SiteWideFacetsQueryBuilder.php index 81921303..268db91b 100644 --- a/src/QueryBuilder/FormQueryBuilder/SiteWideFacetsQueryBuilder.php +++ b/src/QueryBuilder/FormQueryBuilder/SiteWideFacetsQueryBuilder.php @@ -16,7 +16,6 @@ use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface; use Elastica\Query; use Symfony\Component\Form\FormEvent; -use Webmozart\Assert\Assert; final class SiteWideFacetsQueryBuilder implements SiteWideFacetsQueryBuilderInterface { @@ -30,16 +29,12 @@ public function getQuery(FormEvent $event): Query { /** @var Search $data */ $data = $event->getData(); - $box = $data->getBox(); - Assert::notNull($box); - - /** @var Query\BoolQuery $boolQuery */ $boolQuery = $this->queryBuilder->buildQuery([ - 'query' => $box->getQuery() ?? '', + 'query' => $data['box']['query'] ?? '', ]); - foreach ($data->getFacets() as $facetId => $selectedBuckets) { + foreach ($data['facets'] ?? [] as $facetId => $selectedBuckets) { if (!$selectedBuckets) { continue; } @@ -50,4 +45,4 @@ public function getQuery(FormEvent $event): Query return new Query($boolQuery); } -} +} \ No newline at end of file diff --git a/src/QueryBuilder/FormQueryBuilder/TaxonFacetsQueryBuilder.php b/src/QueryBuilder/FormQueryBuilder/TaxonFacetsQueryBuilder.php index 3378c9de..caf68eda 100644 --- a/src/QueryBuilder/FormQueryBuilder/TaxonFacetsQueryBuilder.php +++ b/src/QueryBuilder/FormQueryBuilder/TaxonFacetsQueryBuilder.php @@ -34,7 +34,6 @@ public function getQuery(FormEvent $event, string $namePropertyPrefix): Query $data = $this->shopProductListDataHandler->retrieveData($eventData); - /** @var Query\BoolQuery $boolQuery */ $boolQuery = $this->searchProductsQueryBuilder->buildQuery($data); foreach ($data['facets'] ?? [] as $facetId => $selectedBuckets) { @@ -48,4 +47,4 @@ public function getQuery(FormEvent $event, string $namePropertyPrefix): Query return new Query($boolQuery); } -} +} \ No newline at end of file