Sulu\Bundle\MediaBundle\Entity\CollectionRepositoryInterface::count PHP Method

count() public method

Returns the number of matched collections by a given set of parameters.
public count ( integer $depth, array $filter = [], Sulu\Bundle\MediaBundle\Entity\CollectionInterface $collection = null ) : integer
$depth integer The depth to which collections are loaded
$filter array The array of filters to apply
$collection Sulu\Bundle\MediaBundle\Entity\CollectionInterface
return integer The number of matched collections
    public function count($depth = 0, $filter = [], CollectionInterface $collection = null);

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getTree($locale, $offset, $limit, $search, $depth = 0, $sortBy = [], $systemCollections = true)
 {
     $filter = ['offset' => $offset, 'limit' => $limit, 'search' => $search, 'locale' => $locale, 'systemCollections' => $systemCollections];
     /** @var CollectionEntity[] $entities */
     $entities = $this->collectionRepository->findCollectionSet($depth, $filter, null, $sortBy, $this->getCurrentUser(), $this->permissions[PermissionTypes::VIEW]);
     $collections = [];
     foreach ($entities as $entity) {
         if ($entity->getParent() === null) {
             $collections[] = $this->getApiEntity($entity, $locale, $entities);
         }
     }
     unset($filter['limit']);
     unset($filter['offset']);
     $this->count = $this->collectionRepository->count($depth, $filter);
     return $collections;
 }