Sulu\Bundle\MediaBundle\Media\Manager\MediaManager::move PHP Method

move() public method

public move ( $id, $locale, $destCollection )
    public function move($id, $locale, $destCollection)
    {
        try {
            $mediaEntity = $this->mediaRepository->findMediaById($id);
            if ($mediaEntity === null) {
                throw new MediaNotFoundException($id);
            }
            $mediaEntity->setCollection($this->em->getReference(self::ENTITY_NAME_COLLECTION, $destCollection));
            $this->em->flush();
            return $this->addFormatsAndUrl(new Media($mediaEntity, $locale, null));
        } catch (DBALException $ex) {
            throw new CollectionNotFoundException($destCollection);
        }
    }