Exemplo n.º 1
0
 /**
  * @param array $fieldIds
  * @param array $context
  *
  * @return boolean
  */
 public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds, array $context)
 {
     /** @var \eZ\Publish\Core\FieldType\Image\ImageStorage\Gateway $gateway */
     $gateway = $this->getGateway($context);
     $fieldXmls = $gateway->getXmlForImages($versionInfo->versionNo, $fieldIds);
     foreach ($fieldXmls as $fieldId => $xml) {
         $storedFiles = $this->extractFiles($xml);
         if ($storedFiles === null) {
             continue;
         }
         if ($this->aliasCleaner) {
             $this->aliasCleaner->removeAliases($this->IOService->getExternalPath($storedFiles['original']));
         }
         foreach ($storedFiles as $storedFilePath) {
             $gateway->removeImageReferences($storedFilePath, $versionInfo->versionNo, $fieldId);
             if ($gateway->countImageReferences($storedFilePath) === 0) {
                 try {
                     $binaryFile = $this->IOService->loadBinaryFile($storedFilePath);
                     $this->IOService->deleteBinaryFile($binaryFile);
                 } catch (NotFoundException $e) {
                     if (isset($this->logger)) {
                         $this->logger->error("Image with id {$storedFilePath} not found");
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public function getMimeType($binaryFileId)
 {
     // If the id is an internal (absolute) path to a draft image, use the draft service to get external path & load
     if ($this->isDraftImagePath($binaryFileId)) {
         return $this->draftIOService->getMimeType($this->draftIOService->getExternalPath($binaryFileId));
     }
     // If the id is an internal path (absolute) to a published image, replace with the internal path
     if ($this->isPublishedImagePath($binaryFileId)) {
         $binaryFileId = $this->publishedIOService->getExternalPath($binaryFileId);
     }
     return $this->publishedIOService->getMimeType($binaryFileId);
 }
Exemplo n.º 3
0
 public function removeAliases($originalPath)
 {
     $this->innerAliasCleaner->removeAliases($this->ioService->getExternalPath($originalPath));
 }