improved search with negation (#5453)

This commit is contained in:
Kevin Papst
2025-05-05 18:18:00 +02:00
committed by GitHub
parent 2a9de506a1
commit 452a8d9390
20 changed files with 881 additions and 287 deletions

View File

@@ -21,6 +21,8 @@ use App\Repository\Paginator\PaginatorInterface;
use App\Repository\Query\CustomerFormTypeQuery;
use App\Repository\Query\CustomerQuery;
use App\Repository\Query\CustomerQueryHydrate;
use App\Repository\Search\SearchConfiguration;
use App\Repository\Search\SearchHelper;
use App\Utils\Pagination;
use Doctrine\DBAL\ParameterType;
use Doctrine\ORM\EntityRepository;
@@ -35,8 +37,6 @@ use Doctrine\ORM\QueryBuilder;
*/
class CustomerRepository extends EntityRepository
{
use RepositorySearchTrait;
/**
* @param int[] $customerIDs
* @return array<Customer>
@@ -209,29 +209,17 @@ class CustomerRepository extends EntityRepository
$this->addPermissionCriteria($qb, $query->getCurrentUser(), $query->getTeams());
$this->addSearchTerm($qb, $query);
$configuration = new SearchConfiguration(
['c.name', 'c.comment', 'c.company', 'c.vatId', 'c.number', 'c.contact', 'c.phone', 'c.email', 'c.address'],
CustomerMeta::class,
'customer'
);
$helper = new SearchHelper($configuration);
$helper->addSearchTerm($qb, $query);
return $qb;
}
private function getMetaFieldClass(): string
{
return CustomerMeta::class;
}
private function getMetaFieldName(): string
{
return 'customer';
}
/**
* @return array<string>
*/
private function getSearchableFields(): array
{
return ['c.name', 'c.comment', 'c.company', 'c.vatId', 'c.number', 'c.contact', 'c.phone', 'c.email', 'c.address'];
}
public function getPagerfantaForQuery(CustomerQuery $query): Pagination
{
return new Pagination($this->getPaginatorForQuery($query), $query);