Newscoop\Service\Implementation\AEntityServiceDoctrine::getCount PHP Method

getCount() public method

* ---------------------------------------------------------------
public getCount ( Search $search = NULL )
$search Newscoop\Service\Model\Search\Search
    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];
    }