purge() public method

Delete the image by the given parameters.
public purge ( integer $idMedia, string $fileName, array $options ) : boolean
$idMedia integer
$fileName string
$options array
return boolean
コード例 #1
0
ファイル: MediaManager.php プロジェクト: kriswillis/sulu
 /**
  * {@inheritdoc}
  */
 public function delete($id)
 {
     $mediaEntity = $this->mediaRepository->findMediaById($id);
     if (!$mediaEntity) {
         throw new MediaNotFoundException('Media with the ID ' . $id . ' not found.');
     }
     /** @var File $file */
     foreach ($mediaEntity->getFiles() as $file) {
         /** @var FileVersion $fileVersion */
         foreach ($file->getFileVersions() as $fileVersion) {
             $this->formatManager->purge($mediaEntity->getId(), $fileVersion->getName(), $fileVersion->getStorageOptions());
         }
     }
     $this->em->remove($mediaEntity);
     $this->em->flush();
 }
コード例 #2
0
ファイル: MediaManager.php プロジェクト: gitter-badger/sulu
 /**
  * {@inheritdoc}
  */
 public function delete($id, $checkSecurity = false)
 {
     $mediaEntity = $this->getEntityById($id);
     if ($checkSecurity) {
         $this->securityChecker->checkPermission(new SecurityCondition('sulu.media.collections', null, Collection::class, $mediaEntity->getCollection()->getId()), 'delete');
     }
     /** @var File $file */
     foreach ($mediaEntity->getFiles() as $file) {
         /** @var FileVersion $fileVersion */
         foreach ($file->getFileVersions() as $fileVersion) {
             $this->formatManager->purge($mediaEntity->getId(), $fileVersion->getName(), $fileVersion->getStorageOptions());
             $this->storage->remove($fileVersion->getStorageOptions());
         }
     }
     $this->em->remove($mediaEntity);
     $this->em->flush();
 }
コード例 #3
0
ファイル: FormatOptionsManager.php プロジェクト: sulu/sulu
 /**
  * Purges a file-version of a media with a given id.
  *
  * @param int $mediaId
  * @param FileVersion $fileVersion
  */
 private function purgeMedia($mediaId, FileVersion $fileVersion)
 {
     $this->formatManager->purge($mediaId, $fileVersion->getName(), $fileVersion->getStorageOptions());
 }