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

findCollectionSet() public method

public findCollectionSet ( $depth, $filter = [], Sulu\Bundle\MediaBundle\Entity\CollectionInterface $collection = null, $sortBy = [], Sulu\Component\Security\Authentication\UserInterface $user = null, $permission = null )
$collection Sulu\Bundle\MediaBundle\Entity\CollectionInterface
$user Sulu\Component\Security\Authentication\UserInterface
    public function findCollectionSet($depth = 0, $filter = [], CollectionInterface $collection = null, $sortBy = [], UserInterface $user = null, $permission = null)
    {
        $ids = $this->getIdsQuery($depth, $filter, $sortBy, $collection)->getScalarResult();
        $queryBuilder = $this->createQueryBuilder('collection')->addSelect('collectionMeta')->addSelect('defaultMeta')->addSelect('collectionType')->addSelect('collectionParent')->addSelect('parentMeta')->leftJoin('collection.meta', 'collectionMeta')->leftJoin('collection.defaultMeta', 'defaultMeta')->leftJoin('collection.type', 'collectionType')->leftJoin('collection.parent', 'collectionParent')->leftJoin('collectionParent.meta', 'parentMeta')->where('collection.id IN (:ids)')->setParameter('ids', $ids);
        if ($sortBy !== null && is_array($sortBy) && count($sortBy) > 0) {
            foreach ($sortBy as $column => $order) {
                $queryBuilder->addOrderBy('collectionMeta.' . $column, strtolower($order) === 'asc' ? 'ASC' : 'DESC');
            }
        }
        $queryBuilder->addOrderBy('collection.id', 'ASC');
        if ($user !== null && $permission != null) {
            $this->addAccessControl($queryBuilder, $user, $permission, Collection::class, 'collection');
        }
        return $queryBuilder->getQuery()->getResult();
    }