refactored search with free search term support (#1064)

This commit is contained in:
Kevin Papst
2019-09-04 18:54:06 +02:00
committed by GitHub
parent 49e1a1c410
commit e99b170d0a
147 changed files with 2071 additions and 1322 deletions

View File

@@ -11,6 +11,7 @@ namespace App\Repository\Query;
use App\Entity\Team;
use App\Entity\User;
use App\Utils\SearchTerm;
/**
* Base class for advanced Repository queries.
@@ -55,6 +56,10 @@ class BaseQuery
* @var Team[]
*/
private $teams = [];
/**
* @var SearchTerm|null
*/
private $searchTerm;
public function addTeam(Team $team): self
{
@@ -188,6 +193,27 @@ class BaseQuery
return $this;
}
public function hasSearchTerm(): bool
{
return null !== $this->searchTerm;
}
public function getSearchTerm(): ?SearchTerm
{
return $this->searchTerm;
}
/**
* @param SearchTerm|null $searchTerm
* @return BaseQuery
*/
public function setSearchTerm(?SearchTerm $searchTerm)
{
$this->searchTerm = $searchTerm;
return $this;
}
/**
* Returns whether the query has changed fields, compared to the original state.
*
@@ -203,6 +229,14 @@ class BaseQuery
return true;
}
if (!empty($this->teams)) {
return true;
}
if (null !== $this->searchTerm) {
return true;
}
return false;
}
}