From 79bdb31f3dec22a97eea6d3ca5a6bf78142dd3b6 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 6 Oct 2021 14:41:44 +0200 Subject: [PATCH] add forcedFilterHandlers attribute in RepositoryQuery to force filterHandle to be called in specific use case --- core/Repository/RepositoryQuery.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/Repository/RepositoryQuery.php b/core/Repository/RepositoryQuery.php index 2792efb..5b38eea 100644 --- a/core/Repository/RepositoryQuery.php +++ b/core/Repository/RepositoryQuery.php @@ -17,6 +17,7 @@ abstract class RepositoryQuery protected QueryBuilder $query; protected PaginatorInterface $paginator; protected string $id; + protected array $forcedFilterHandlers; public function __construct(ServiceEntityRepository $repository, string $id, PaginatorInterface $paginator = null) { @@ -24,6 +25,7 @@ abstract class RepositoryQuery $this->query = $repository->createQueryBuilder($id); $this->paginator = $paginator; $this->id = $id; + $this->forcedFilterHandlers = []; } public function __call(string $name, $params): self @@ -81,7 +83,9 @@ abstract class RepositoryQuery continue; } - if (is_int($value) || is_bool($value)) { + if (in_array($name, $this->forcedFilterHandlers)) { + $this->filterHandler($name, $value); + } elseif (is_int($value) || is_bool($value)) { $this->andWhere('.'.$name.' = :'.$name); $this->setParameter(':'.$name, $value); } elseif (is_string($value)) {