Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Controller/Action/SearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
use Setono\SyliusMeilisearchPlugin\Event\Search\SearchResponseParametersCreated;
use Setono\SyliusMeilisearchPlugin\Event\Search\SearchResultReceived;
use Setono\SyliusMeilisearchPlugin\Form\Builder\SearchFormBuilderInterface;
use Setono\SyliusMeilisearchPlugin\Form\Type\SearchResultType;
use Setono\SyliusMeilisearchPlugin\Model\IndexableInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;
Expand All @@ -22,8 +24,9 @@
{
use ORMTrait;

public function __construct(

Check failure on line 27 in src/Controller/Action/SearchAction.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The number of required arguments for Setono\SyliusMeilisearchPlugin\Controller\Action\SearchAction#__construct() increased from 5 to 6

Check failure on line 27 in src/Controller/Action/SearchAction.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The parameter $twig of Setono\SyliusMeilisearchPlugin\Controller\Action\SearchAction#__construct() changed from Twig\Environment to a non-contravariant Symfony\Component\Form\FormFactoryInterface

Check failure on line 27 in src/Controller/Action/SearchAction.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The parameter $searchFormBuilder of Setono\SyliusMeilisearchPlugin\Controller\Action\SearchAction#__construct() changed from Setono\SyliusMeilisearchPlugin\Form\Builder\SearchFormBuilderInterface to a non-contravariant Twig\Environment

Check failure on line 27 in src/Controller/Action/SearchAction.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The parameter $searchEngine of Setono\SyliusMeilisearchPlugin\Controller\Action\SearchAction#__construct() changed from Setono\SyliusMeilisearchPlugin\Engine\SearchEngineInterface to a non-contravariant Setono\SyliusMeilisearchPlugin\Form\Builder\SearchFormBuilderInterface

Check failure on line 27 in src/Controller/Action/SearchAction.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The parameter $eventDispatcher of Setono\SyliusMeilisearchPlugin\Controller\Action\SearchAction#__construct() changed from Psr\EventDispatcher\EventDispatcherInterface to a non-contravariant Setono\SyliusMeilisearchPlugin\Engine\SearchEngineInterface
ManagerRegistry $managerRegistry,
private readonly FormFactoryInterface $formFactory,
private readonly Environment $twig,
private readonly SearchFormBuilderInterface $searchFormBuilder,
private readonly SearchEngineInterface $searchEngine,
Expand All @@ -40,7 +43,7 @@
$searchResult = $this->searchEngine->execute($searchRequestCreatedEvent->searchRequest);
$this->eventDispatcher->dispatch(new SearchResultReceived($searchResult));

$searchForm = $this->searchFormBuilder->build($searchResult);
$searchForm = $this->formFactory->create(SearchResultType::class, $searchResult);

Check warning on line 46 in src/Controller/Action/SearchAction.php

View check run for this annotation

Codecov / codecov/patch

src/Controller/Action/SearchAction.php#L46

Added line #L46 was not covered by tests
$searchForm->handleRequest($request);

if ($searchForm->isSubmitted() && !$searchForm->isValid()) {
Expand Down
4 changes: 3 additions & 1 deletion src/Engine/SearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@

final class SearchResult
{
public function __construct(

Check failure on line 13 in src/Engine/SearchResult.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The number of required arguments for Setono\SyliusMeilisearchPlugin\Engine\SearchResult#__construct() increased from 7 to 8

Check failure on line 13 in src/Engine/SearchResult.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The parameter $hits of Setono\SyliusMeilisearchPlugin\Engine\SearchResult#__construct() changed from array to a non-contravariant string

Check failure on line 13 in src/Engine/SearchResult.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The parameter $totalHits of Setono\SyliusMeilisearchPlugin\Engine\SearchResult#__construct() changed from int to a non-contravariant array

Check failure on line 13 in src/Engine/SearchResult.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The parameter $facetDistribution of Setono\SyliusMeilisearchPlugin\Engine\SearchResult#__construct() changed from Setono\SyliusMeilisearchPlugin\Engine\FacetDistribution to a non-contravariant int
/** The index that was queried */
public readonly Index $index,

public readonly string $query,
/** @var array<int, array> $hits */
public readonly array $hits,
public readonly int $totalHits,
public readonly int $page,
public readonly int $pageSize,
public readonly int $totalPages,
public readonly FacetDistribution $facetDistribution,
public readonly ?string $sort = null,
) {
}

Expand All @@ -44,6 +45,7 @@

return new self(
$index,
$meilisearchSearchResult->getQuery(),

Check warning on line 48 in src/Engine/SearchResult.php

View check run for this annotation

Codecov / codecov/patch

src/Engine/SearchResult.php#L48

Added line #L48 was not covered by tests
$meilisearchSearchResult->getHits(),
$totalHits,
$page,
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Builder/SearchFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'csrf_protection' => false,
'allow_extra_fields' => true,
])
->add('q', HiddenType::class)
->add(SearchRequest::QUERY_PARAMETER_FILTER, HiddenType::class)

Check warning on line 38 in src/Form/Builder/SearchFormBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Builder/SearchFormBuilder.php#L38

Added line #L38 was not covered by tests
->setMethod('GET')
;

Expand Down Expand Up @@ -79,7 +79,7 @@
$choices['setono_sylius_meilisearch.form.search.pagination.next'] = $searchResult->page + 1;
}

$builder->add('p', ChoiceType::class, [
$builder->add(SearchRequest::QUERY_PARAMETER_PAGE, ChoiceType::class, [

Check warning on line 82 in src/Form/Builder/SearchFormBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Builder/SearchFormBuilder.php#L82

Added line #L82 was not covered by tests
'choices' => $choices,
'choice_attr' => fn (string $page) => ['style' => 'display: none'], // we only want to display the labels
'required' => false,
Expand Down
20 changes: 20 additions & 0 deletions src/Form/Type/SearchFilterType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusMeilisearchPlugin\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

final class SearchFilterType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void

Check warning on line 13 in src/Form/Type/SearchFilterType.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Type/SearchFilterType.php#L13

Added line #L13 was not covered by tests
{
}

Check warning on line 15 in src/Form/Type/SearchFilterType.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Type/SearchFilterType.php#L15

Added line #L15 was not covered by tests

public function configureOptions(OptionsResolver $resolver): void

Check warning on line 17 in src/Form/Type/SearchFilterType.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Type/SearchFilterType.php#L17

Added line #L17 was not covered by tests
{
}

Check warning on line 19 in src/Form/Type/SearchFilterType.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Type/SearchFilterType.php#L19

Added line #L19 was not covered by tests
}
22 changes: 22 additions & 0 deletions src/Form/Type/SearchResultSortType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusMeilisearchPlugin\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

final class SearchResultSortType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)

Check failure on line 16 in src/Form/Type/SearchResultSortType.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: lowest | SF~5.4.0)

MissingReturnType

src/Form/Type/SearchResultSortType.php:16:21: MissingReturnType: Method Setono\SyliusMeilisearchPlugin\Form\Type\SearchResultSortType::buildForm does not have a return type, expecting void (see https://psalm.dev/050)

Check failure on line 16 in src/Form/Type/SearchResultSortType.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.1 | Deps: lowest | SF~5.4.0)

MissingReturnType

src/Form/Type/SearchResultSortType.php:16:21: MissingReturnType: Method Setono\SyliusMeilisearchPlugin\Form\Type\SearchResultSortType::buildForm does not have a return type, expecting void (see https://psalm.dev/050)

Check failure on line 16 in src/Form/Type/SearchResultSortType.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~5.4.0)

MissingReturnType

src/Form/Type/SearchResultSortType.php:16:21: MissingReturnType: Method Setono\SyliusMeilisearchPlugin\Form\Type\SearchResultSortType::buildForm does not have a return type, expecting void (see https://psalm.dev/050)

Check warning on line 16 in src/Form/Type/SearchResultSortType.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Type/SearchResultSortType.php#L16

Added line #L16 was not covered by tests
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
dump($event->getData());

Check failure on line 19 in src/Form/Type/SearchResultSortType.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.1 | Deps: highest | SF~6.4.0)

ForbiddenCode

src/Form/Type/SearchResultSortType.php:19:13: ForbiddenCode: You have forbidden the use of dump (see https://psalm.dev/002)

Check failure on line 19 in src/Form/Type/SearchResultSortType.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~6.4.0)

ForbiddenCode

src/Form/Type/SearchResultSortType.php:19:13: ForbiddenCode: You have forbidden the use of dump (see https://psalm.dev/002)

Check failure on line 19 in src/Form/Type/SearchResultSortType.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: lowest | SF~5.4.0)

ForbiddenCode

src/Form/Type/SearchResultSortType.php:19:13: ForbiddenCode: You have forbidden the use of dump (see https://psalm.dev/002)

Check failure on line 19 in src/Form/Type/SearchResultSortType.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.1 | Deps: lowest | SF~5.4.0)

ForbiddenCode

src/Form/Type/SearchResultSortType.php:19:13: ForbiddenCode: You have forbidden the use of dump (see https://psalm.dev/002)

Check failure on line 19 in src/Form/Type/SearchResultSortType.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: highest | SF~5.4.0)

ForbiddenCode

src/Form/Type/SearchResultSortType.php:19:13: ForbiddenCode: You have forbidden the use of dump (see https://psalm.dev/002)

Check failure on line 19 in src/Form/Type/SearchResultSortType.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (PHP8.2 | Deps: lowest | SF~6.4.0)

ForbiddenCode

src/Form/Type/SearchResultSortType.php:19:13: ForbiddenCode: You have forbidden the use of dump (see https://psalm.dev/002)
});

Check warning on line 20 in src/Form/Type/SearchResultSortType.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Type/SearchResultSortType.php#L18-L20

Added lines #L18 - L20 were not covered by tests
}
}
29 changes: 29 additions & 0 deletions src/Form/Type/SearchResultType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusMeilisearchPlugin\Form\Type;

use Setono\SyliusMeilisearchPlugin\Engine\SearchRequest;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;

final class SearchResultType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void

Check warning on line 16 in src/Form/Type/SearchResultType.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Type/SearchResultType.php#L16

Added line #L16 was not covered by tests
{
$builder
->add(SearchRequest::QUERY_PARAMETER_SEARCH, HiddenType::class, [
'property_path' => 'query',
])
// ->add(SearchRequest::QUERY_PARAMETER_FILTER, SearchFilterType::class)
->add(SearchRequest::QUERY_PARAMETER_SORT, SearchResultSortType::class, [
'property_path' => 'sort',
])
->setMethod('GET')
;

Check warning on line 27 in src/Form/Type/SearchResultType.php

View check run for this annotation

Codecov / codecov/patch

src/Form/Type/SearchResultType.php#L18-L27

Added lines #L18 - L27 were not covered by tests
}
}
1 change: 1 addition & 0 deletions src/Resources/config/services/conditional/search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<service id="Setono\SyliusMeilisearchPlugin\Controller\Action\SearchAction" public="true">
<argument type="service" id="doctrine"/>
<argument type="service" id="form.factory"/>
<argument type="service" id="twig"/>
<argument type="service" id="Setono\SyliusMeilisearchPlugin\Form\Builder\SearchFormBuilderInterface"/>
<argument type="service" id="Setono\SyliusMeilisearchPlugin\Engine\SearchEngineInterface"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/search/_filters.html.twig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ form_widget(searchForm.f, { 'attr': { 'class': 'ssm-filters' } }) }}
{#{{ form_widget(searchForm.f, { 'attr': { 'class': 'ssm-filters' } }) }}#}
Loading