Sulu\Bundle\MediaBundle\Entity\CollectionRepository::countSubCollections PHP Method

countSubCollections() public method

public countSubCollections ( Sulu\Bundle\MediaBundle\Entity\CollectionInterface $collection )
$collection Sulu\Bundle\MediaBundle\Entity\CollectionInterface
    public function countSubCollections(CollectionInterface $collection)
    {
        if (!$collection || !$collection->getId()) {
            throw new \InvalidArgumentException();
        }
        $queryBuilder = $this->createQueryBuilder('collection')->select('COUNT(subCollections.id)')->leftJoin('collection.children', 'subCollections')->where('collection.id = :id')->setParameter('id', $collection->getId());
        return intval($queryBuilder->getQuery()->getSingleScalarResult());
    }