add count method on repository query
add addForcedFilterHandler method
This commit is contained in:
parent
8d5de79192
commit
21ee41ff29
|
@ -98,6 +98,15 @@ abstract class RepositoryQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function addForcedFilterHandler(string $name): self
|
||||
{
|
||||
if (in_array($name, $this->forcedFilterHandlers)) {
|
||||
$this->forcedFilterHandlers[] = $name;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function populateDqlId(&$data)
|
||||
{
|
||||
if (is_string($data)) {
|
||||
|
@ -122,4 +131,15 @@ abstract class RepositoryQuery
|
|||
protected function filterHandler(string $name, $value)
|
||||
{
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
return $this
|
||||
->select(sprintf('COUNT(%s.id) as total', $this->id))
|
||||
->query
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getOneOrNullResult()['total']
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue