Skip to content

Commit

Permalink
Introduce the SearchEngineInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubtobiasz committed Aug 21, 2024
1 parent cae93a3 commit 9544739
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Controller/Action/SearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Doctrine\Persistence\ManagerRegistry;
use Setono\Doctrine\ORMTrait;
use Setono\SyliusMeilisearchPlugin\Engine\SearchEngine;
use Setono\SyliusMeilisearchPlugin\Engine\SearchEngineInterface;
use Setono\SyliusMeilisearchPlugin\Form\Builder\SearchFormBuilderInterface;
use Setono\SyliusMeilisearchPlugin\Model\IndexableInterface;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -22,7 +22,7 @@ public function __construct(
ManagerRegistry $managerRegistry,
private readonly Environment $twig,
private readonly SearchFormBuilderInterface $searchFormBuilder,
private readonly SearchEngine $searchEngine,
private readonly SearchEngineInterface $searchEngine,
) {
$this->managerRegistry = $managerRegistry;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/SearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Setono\SyliusMeilisearchPlugin\Meilisearch\Builder\FilterBuilderInterface;
use Setono\SyliusMeilisearchPlugin\Resolver\IndexName\IndexNameResolverInterface;

final class SearchEngine
final class SearchEngine implements SearchEngineInterface
{
public function __construct(
private readonly MetadataFactoryInterface $metadataFactory,
Expand Down
12 changes: 12 additions & 0 deletions src/Engine/SearchEngineInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusMeilisearchPlugin\Engine;

use Meilisearch\Search\SearchResult;

interface SearchEngineInterface
{
public function execute(?string $query, array $parameters = []): SearchResult;
}
6 changes: 4 additions & 2 deletions src/Resources/config/services/conditional/search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@
<argument type="service" id="doctrine"/>
<argument type="service" id="twig"/>
<argument type="service" id="Setono\SyliusMeilisearchPlugin\Form\Builder\SearchFormBuilderInterface"/>
<argument type="service" id="Setono\SyliusMeilisearchPlugin\Engine\SearchEngine" />
<argument type="service" id="Setono\SyliusMeilisearchPlugin\Engine\SearchEngineInterface" />
</service>

<service id="Setono\SyliusMeilisearchPlugin\Engine\SearchEngine" public="true">
<service id="Setono\SyliusMeilisearchPlugin\Engine\SearchEngine">
<argument type="service" id="Setono\SyliusMeilisearchPlugin\Document\Metadata\MetadataFactoryInterface"/>
<argument type="service" id="Setono\SyliusMeilisearchPlugin\Meilisearch\Builder\FilterBuilderInterface"/>
<argument type="service" id="setono_sylius_meilisearch.index.search"/>
<argument type="service" id="setono_sylius_meilisearch.resolver.index_name"/>
<argument type="service" id="Meilisearch\Client"/>
<argument>%setono_sylius_meilisearch.search.hits_per_page%</argument>
</service>

<service id="Setono\SyliusMeilisearchPlugin\Engine\SearchEngineInterface" alias="Setono\SyliusMeilisearchPlugin\Engine\SearchEngine" />
</services>
</container>

0 comments on commit 9544739

Please sign in to comment.