Skip to content

Commit

Permalink
Merge pull request #134 from monsieurbiz/fix/space-into-query
Browse files Browse the repository at this point in the history
Trim the query in request
  • Loading branch information
jacquesbh authored Aug 17, 2022
2 parents 846cfa0 + 0cb9a72 commit c4eb8e3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
- name: Install symfony CLI
run: |
curl https://get.symfony.com/cli/installer | bash
echo "${HOME}/.symfony/bin" >> $GITHUB_PATH
curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash
sudo apt install symfony-cli
- uses: actions/cache@v1
id: cache-composer
Expand Down
4 changes: 2 additions & 2 deletions src/Search/Request/ProductRequest/InstantSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function getDocumentable(): DocumentableInterface

public function getQuery(): Query
{
if (null === $this->configuration || '' === $this->configuration->getQueryText()) {
throw new RuntimeException('missing query text');
if (null === $this->configuration) {
throw new RuntimeException('missing configuration');
}

$qb = new QueryBuilder();
Expand Down
5 changes: 0 additions & 5 deletions src/Search/Request/ProductRequest/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use MonsieurBiz\SyliusSearchPlugin\Search\Request\RequestConfiguration;
use MonsieurBiz\SyliusSearchPlugin\Search\Request\RequestInterface;
use MonsieurBiz\SyliusSearchPlugin\Search\Request\Sorting\SorterRegistryInterface;
use RuntimeException;
use Sylius\Component\Registry\ServiceRegistryInterface;

final class Search implements RequestInterface
Expand Down Expand Up @@ -87,10 +86,6 @@ public function setConfiguration(RequestConfiguration $configuration): void

public function getQuery(): Query
{
if ('' === $this->configuration->getQueryText()) {
throw new RuntimeException('missing query text');
}

$qb = new QueryBuilder();

$boolQuery = $qb->query()->bool();
Expand Down
2 changes: 1 addition & 1 deletion src/Search/Request/RequestConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(

public function getQueryText(): string
{
return $this->request->get('query', '');
return trim($this->request->get('query', ''));
}

public function getAppliedFilters(string $type = null): array
Expand Down

0 comments on commit c4eb8e3

Please sign in to comment.