/**
  * Deletes all referenced external data
  *
  * @param VersionInfo $versionInfo
  * @param array $fieldIds
  * @param array $context
  *
  * @return boolean
  */
 public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds, array $context)
 {
     if (empty($fieldIds)) {
         return;
     }
     $gateway = $this->getGateway($context);
     $referencedFiles = $gateway->getReferencedFiles($fieldIds, $versionInfo->versionNo);
     $gateway->removeFileReferences($fieldIds, $versionInfo->versionNo);
     $referenceCountMap = $gateway->countFileReferences($referencedFiles);
     foreach ($referenceCountMap as $filePath => $count) {
         if ($count === 0) {
             try {
                 $binaryFile = $this->IOService->loadBinaryFile($filePath);
                 $this->IOService->deleteBinaryFile($binaryFile);
             } catch (NotFoundException $e) {
                 if (isset($this->logger)) {
                     $filePath = $this->IOService->getInternalPath($filePath);
                     $this->logger->error("BinaryFile with ID {$filePath} not found");
                 }
             }
         }
     }
 }
示例#2
0
 public function getInternalPath($externalId)
 {
     return $this->publishedIOService->getInternalPath($externalId);
 }