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

findCollectionById() public method

Finds the collection with a given id.
public findCollectionById ( integer $id ) : Collection
$id integer
return Collection
    public function findCollectionById($id);

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function move($id, $locale, $destinationId = null)
 {
     try {
         $collectionEntity = $this->collectionRepository->findCollectionById($id);
         if ($collectionEntity === null) {
             throw new CollectionNotFoundException($id);
         }
         $destinationEntity = null;
         if ($destinationId !== null) {
             $destinationEntity = $this->collectionRepository->findCollectionById($destinationId);
         }
         $collectionEntity->setParent($destinationEntity);
         $this->em->flush();
         return $this->getApiEntity($collectionEntity, $locale);
     } catch (DBALException $ex) {
         throw new CollectionNotFoundException($destinationId);
     }
 }