remove() public method

Removes the file from storage.
public remove ( $storageOption ) : mixed
$storageOption
return mixed
示例#1
0
 /**
  * {@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()), PermissionTypes::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();
 }