backports murph-skeleton

This commit is contained in:
Simon Vieille 2021-04-26 11:28:47 +02:00
parent c15ce9da3e
commit 146533af30

View file

@ -94,4 +94,29 @@ abstract class RepositoryQuery
return $data;
}
protected function filterHandler(string $name, $value)
{
}
public function useFilters(array $filters)
{
foreach ($filters as $name => $value) {
if (null === $value) {
continue;
}
if (is_int($value) || is_bool($value)) {
$this->andWhere('.'.$name.' = :'.$name);
$this->setParameter(':'.$name, $value);
} elseif (is_string($value)) {
$this->andWhere('.'.$name.' LIKE :'.$name);
$this->setParameter(':'.$name, '%'.$value.'%');
} else {
$this->filterHandler($name, $value);
}
}
return $this;
}
}