Purges a file-version of a media with a given id.

@param int $mediaId
@param FileVersion $fileVersion
12483
private function purgeMedia($mediaId, FileVersion $fileVersion)
    {
        $this->formatManager->purge(
            $mediaId,
            $fileVersion->getName(),
            $fileVersion->getMimeType(),
            $fileVersion->getStorageOptions()
        );
    }
791049
static function removeById( $attributeId, $version = null )
    {
        if ( $version !== null )
    	   $conds = array( 'contentobject_attribute_id' => $attributeId, 'contentobject_version' => $version  );
    	else
    	    $conds = array( 'contentobject_attribute_id' => $attributeId );

        eZPersistentObject::removeObject( self::definition(), $conds, null );
    }
969872
public function deleteRevision($contentId, $revisionId)
    {
        $this->loadModel('Content.ContentRevisions');
        $revision = $this->ContentRevisions->find()
            ->where(['id' => $revisionId, 'content_id' => $contentId])
            ->first();

        if ($this->ContentRevisions->delete($revision, ['atomic' => true])) {
            $this->Flash->success(__d('content', 'Revision was successfully removed!'));
        } else {
            $this->Flash->danger(__d('content', 'Unable to remove this revision, please try again.'));
        }

        $this->title(__d('content', 'Editing Content Revision'));
        $this->redirect($this->referer());
    }
1026581
public function deleteAction($productId, $mediaId)
    {
        /** @var Product $product */
        $product = $this->getProductRepository()->find($productId);
        if (!$product) {
            throw new EntityNotFoundException($this->getProductEntityName(), $productId);
        }

        $this->getProductMediaManager()->delete($product, [$mediaId]);

        $view = $this->view(null, Response::HTTP_NO_CONTENT);
        $this->getEntityManager()->flush();

        return $this->handleView($view);
    }
377968
public function deleteVersionAction(Request $request, $id, $version)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);
        $mediaManager = $this->getMediaManager();
        $media = $mediaManager->getById($id, $locale);

        if ($media->getVersion() === (int) $version) {
            throw new BadRequestHttpException('Can\'t delete active version of a media.');
        }

        $currentFileVersion = null;

        /** @var Media $mediaEntity */
        foreach ($media->getFile()->getFileVersions() as $fileVersion) {
            if ($fileVersion->getVersion() === (int) $version) {
                $currentFileVersion = $fileVersion;
                break;
            }
        }

        if (!$currentFileVersion) {
            throw new NotFoundHttpException(sprintf(
                'Version "%s" for Media "%s"',
                $version,
                $id
            ));
        }

        $entityManager = $this->get('doctrine.orm.entity_manager');
        $entityManager->remove($currentFileVersion);
        $entityManager->flush();
        // After successfully delete in the database remove file from storage
        $this->get('sulu_media.storage')->remove($currentFileVersion->getStorageOptions());

        return new Response('', 204);
    }
727951
private function getFile($fileId)
    {
        if (!$fileId) {
            return null;
        }

        $volumeManager = $this->getContainer()->get('phlexible_media_manager.volume_manager');
        $volume = $volumeManager->getByFileId($fileId);
        $file = $volume->findFile($fileId);

        return $file;
    }
1126919
protected void purgeFile(String rfsFilePath, String vfsName) {

        File rfsFile = new File(rfsFilePath);

        // first delete the base file
        deleteFile(rfsFile, vfsName);

        // now delete the file parameter variations
        // get the parent folder
        File parent = rfsFile.getParentFile();
        if (parent != null) {
            // list all files in the parent folder that are variations of the base file
            File[] paramVariants = parent.listFiles(new PrefixFileFilter(rfsFile));
            if (paramVariants != null) {
                for (int v = 0; v < paramVariants.length; v++) {
                    deleteFile(paramVariants[v], vfsName);
                }
            }
        }
    }
1123566
public function deleteAlternatives(MediaInterface $media)
    {
        foreach ($media->getAlternatives() as $storageKey) {
            $this->deleteFile($storageKey);
        }

        parent::deleteAlternatives($media);
    }
254138
protected function getFileVersion($id, $version)
    {
        /** @var MediaInterface $mediaEntity */
        $mediaEntity = $this->container->get('sulu.repository.media')->findMediaById($id);

        if (!$mediaEntity) {
            return null;
        }

        $file = $mediaEntity->getFiles()[0];

        if (!$file) {
            return null;
        }

        if (!$version) {
            $version = $mediaEntity->getFiles()[0]->getVersion();
        }

        $fileVersion = $file->getFileVersion((int) $version);

        if (!$fileVersion) {
            throw new FileVersionNotFoundException($id, $version);
        }

        return $fileVersion;
    }
155001
public function deleteVersion($contentId, $versionNo)
    {
        $versionInfo = $this->loadVersionInfo($contentId, $versionNo);

        $this->locationGateway->deleteNodeAssignment($contentId, $versionNo);

        $this->fieldHandler->deleteFields($contentId, $versionInfo);

        $this->contentGateway->deleteRelations($contentId, $versionNo);
        $this->contentGateway->deleteVersions($contentId, $versionNo);
        $this->contentGateway->deleteNames($contentId, $versionNo);
    }
863277
public function handleVersionedService($version, $service, $resource = null)
    {
        $request = new ServiceRequest();
        $request->setApiVersion($version);

        return $this->handleServiceRequest($request, $service, $resource);
    }
153427
static function purgeForObject( $contentObjectID )
    {
        if ( !is_numeric( $contentObjectID ) )
            return false;
        $db = eZDB::instance();
        $db->begin();
        $db->query( "DELETE FROM ezcontentobject_trash WHERE contentobject_id='$contentObjectID'" );
        $db->commit();
    }
165818
public void purge(@NonNull String id) throws CouchbaseLiteException {
        if (id == null) { throw new IllegalArgumentException("document id cannot be null."); }

        synchronized (lock) {
            boolean commit = false;
            beginTransaction();
            try {
                getC4Database().purgeDoc(id);
                commit = true;
            }
            catch (LiteCoreException e) {
                throw CBLStatus.convertException(e);
            }
            finally {
                endTransaction(commit);
            }
        }
    }
1087417
public function delete(ResourceManager $resourceManager, ApiRequest $request, int $version, string $resource, $id)
    {
        $resourceManager->version($version);

        /** @var \Ipunkt\LaravelJsonApi\Contracts\RequestHandlers\HandlesDeleteRequest $handler */
        $handler = $this->initializeHandler($resourceManager, $resource, $request, HandlesDeleteRequest::class);

        $handler->delete($id, $request);

        return $this->respondNoContent();
    }
944845
public function removeAction($mediaId)
    {
        $media = $this->getMedia($mediaId);
        $request = $this->getRequest();
        if ($request->request->get('confirm') === 'yes' || $request->get('confirm') === 'yes')
        {
            $this->get('fulgurio_light_cms.media_library')->remove($media);
            $em = $this->getDoctrine()->getManager();
            $em->remove($media);
            $em->flush();
            return $this->redirect($this->generateUrl('AdminMedias'));
        }
        else if ($request->request->get('confirm') === 'no')
        {
            return $this->redirect($this->generateUrl('AdminMedias', array('mediaId' => $mediaId)));
        }
        $templateName = $request->isXmlHttpRequest() ? 'FulgurioLightCMSBundle::adminConfirmAjax.html.twig' : 'FulgurioLightCMSBundle::adminConfirm.html.twig';
        return $this->render($templateName, array(
            'action' => $this->generateUrl('AdminMediasRemove', array('mediaId' => $mediaId)),
            'confirmationMessage' => $this->get('translator')->trans('fulgurio.lightcms.medias.delete_confirm_message', array('%FILENAME%' => $media->getOriginalName()), 'admin'),
        ));
    }
1309735
public function deleteContent($contentId, $versionId = null)
    {
        // 1. Delete the Content
        if ($versionId === null) {
            $this->gateway->deleteByQuery(json_encode(['query' => ['match' => ['_id' => $contentId]]]), $this->contentDocumentTypeIdentifier);
        } else {
            $this->gateway->delete($contentId, $this->contentDocumentTypeIdentifier);
        }

        // 2. Delete all Content's Locations
        $this->gateway->deleteByQuery(json_encode(['query' => ['match' => ['content_id_id' => $contentId]]]), $this->locationDocumentTypeIdentifier);
    }
1012125
function trashStoredObjectAttribute( $contentObjectAttribute, $version = null )
    {
        $contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );
        $sys = eZSys::instance();
        $storage_dir = $sys->storageDirectory();

        if ( $version == null )
            $mediaFiles = eZMedia::fetch( $contentObjectAttributeID, null );
        else
            $mediaFiles = array( eZMedia::fetch( $contentObjectAttributeID, $version ) );

        foreach ( $mediaFiles as $mediaFile )
        {
            if ( $mediaFile == null )
                continue;
            $mimeType =  $mediaFile->attribute( "mime_type" );
            list( $prefix, $suffix ) = explode( '/', $mimeType );
            $orig_dir = $storage_dir . '/original/' . $prefix;
            $fileName = $mediaFile->attribute( "filename" );

            // Check if there are any other records in ezmedia that point to that fileName.
            $mediaObjectsWithSameFileName = eZMedia::fetchByFileName( $fileName );

            $filePath = $orig_dir . "/" . $fileName;
            $file = eZClusterFileHandler::instance( $filePath );

            if ( $file->exists() and count( $mediaObjectsWithSameFileName ) <= 1 )
            {
                // create dest filename in the same manner as eZHTTPFile::store()
                // grab file's suffix
                $fileSuffix = eZFile::suffix( $fileName );
                // prepend dot
                if ( $fileSuffix )
                    $fileSuffix = '.' . $fileSuffix;
                // grab filename without suffix
                $fileBaseName = basename( $fileName, $fileSuffix );
                // create dest filename
                $newFileName = md5( $fileBaseName . microtime() . mt_rand() ) . $fileSuffix;
                $newFilePath = $orig_dir . "/" . $newFileName;

                // rename the file, and update the database data
                $file->move( $newFilePath );
                $mediaFile->setAttribute( 'filename', $newFileName );
                $mediaFile->store();
            }
        }
    }