function getCount(Search $search = NULL)
{
$qb = $this->getManager()->createQueryBuilder();
$qb->select('COUNT(' . self::ALIAS . ')')->from($this->entityClassName, self::ALIAS);
if ($search !== NULL) {
if (get_class($search) !== $this->searchClassName) {
throw new \Exception("The search needs to be a '.{$this->searchClassName}.' instance.");
}
$this->processInterogation($search, $qb);
}
$result = $qb->getQuery()->getResult();
return (int) $result[0][1];
}