Skip to content

Commit

Permalink
Merge pull request #189 from delyriand/fix/elasticsearch-checker-host…
Browse files Browse the repository at this point in the history
…-config

Add config with url in checker to avoid error couldn’t resolve host
  • Loading branch information
delyriand authored Aug 30, 2023
2 parents 1930ec3 + f326f58 commit 0393453
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Checker/ElasticsearchChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ class ElasticsearchChecker implements ElasticsearchCheckerInterface
{
private ?bool $isAvailable = null;

private array $config;

public function __construct(array $config = [])
{
$this->config = $config;
}

public function check(): bool
{
if (null === $this->isAvailable) {
$client = (new Factory())->buildClient();
$client = (new Factory($this->config))->buildClient();

// Check client response
try {
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ services:

monsieurbiz.search.checker.elasticsearch_checker:
class: MonsieurBiz\SyliusSearchPlugin\Checker\ElasticsearchChecker
arguments:
$config:
url: '%monsieurbiz_search_elasticsearch_url%'

MonsieurBiz\SyliusSearchPlugin\Twig\Extension\RenderSearchForm:
arguments:
Expand Down

0 comments on commit 0393453

Please sign in to comment.