mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 04:23:49 +00:00
replace search api by a first workin implementation
This commit is contained in:
85
src/Bundle/ChillMainBundle/Search/SearchApiQuery.php
Normal file
85
src/Bundle/ChillMainBundle/Search/SearchApiQuery.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Search;
|
||||
|
||||
class SearchApiQuery
|
||||
{
|
||||
private ?string $selectKey;
|
||||
private array $selectKeyParams = [];
|
||||
private ?string $jsonbMetadata;
|
||||
private array $jsonbMetadataParams = [];
|
||||
private ?string $pertinence;
|
||||
private array $pertinenceParams = [];
|
||||
private ?string $fromClause;
|
||||
private array $fromClauseParams = [];
|
||||
private ?string $whereClause;
|
||||
private array $whereClauseParams = [];
|
||||
|
||||
public function setSelectKey(string $selectKey, array $params = []): self
|
||||
{
|
||||
$this->selectKey = $selectKey;
|
||||
$this->selectKeyParams = $params;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSelectJsonbMetadata(string $jsonbMetadata, array $params = []): self
|
||||
{
|
||||
$this->jsonbMetadata = $jsonbMetadata;
|
||||
$this->jsonbMetadataParams = $params;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSelectPertinence(string $pertinence, array $params = []): self
|
||||
{
|
||||
$this->pertinence = $pertinence;
|
||||
$this->pertinenceParams = $params;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFromClause(string $fromClause, array $params = []): self
|
||||
{
|
||||
$this->fromClause = $fromClause;
|
||||
$this->fromClauseParams = $params;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setWhereClause(string $whereClause, array $params = []): self
|
||||
{
|
||||
$this->whereClause = $whereClause;
|
||||
$this->whereClauseParams = $params;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function buildQuery(): string
|
||||
{
|
||||
return \strtr("SELECT
|
||||
{key} AS key,
|
||||
{metadata} AS metadata,
|
||||
{pertinence} AS pertinence
|
||||
FROM {from}
|
||||
WHERE {where}
|
||||
", [
|
||||
'{key}' => $this->selectKey,
|
||||
'{metadata}' => $this->jsonbMetadata,
|
||||
'{pertinence}' => $this->pertinence,
|
||||
'{from}' => $this->fromClause,
|
||||
'{where}' => $this->whereClause
|
||||
]);
|
||||
}
|
||||
|
||||
public function buildParameters(): array
|
||||
{
|
||||
return \array_merge(
|
||||
$this->selectKeyParams,
|
||||
$this->jsonbMetadataParams,
|
||||
$this->pertinenceParams,
|
||||
$this->fromClauseParams,
|
||||
$this->whereClauseParams
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user