public function testRemoveAliases()
 {
     $originalPath = 'foo/bar/test.jpg';
     $this->urlRedecorator->expects($this->once())->method('redecorateFromTarget')->with($originalPath);
     $this->innerAliasCleaner->expects($this->once())->method('removeAliases');
     $this->aliasCleaner->removeAliases($originalPath);
 }
Example #2
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");
                     }
                 }
             }
         }
     }
 }
    /**
     * @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 = $gateway->extractFilesFromXml( $xml );
            if ( $storedFiles === null )
            {
                continue;
            }

            if ( $this->aliasCleaner )
            {
                $this->aliasCleaner->removeAliases( $storedFiles['original'] );
            }

            foreach ( $storedFiles as $storedFilePath )
            {
                $gateway->removeImageReferences( $storedFilePath, $versionInfo->versionNo, $fieldId );
                if ( $gateway->countImageReferences( $storedFilePath ) === 0 )
                {
                    $binaryFile = $this->IOService->loadBinaryFileByUri( $storedFilePath );
                    $this->IOService->deleteBinaryFile( $binaryFile );
                }
            }
        }
    }
 public function removeAliases($originalPath)
 {
     $this->innerAliasCleaner->removeAliases($this->ioService->loadBinaryFileByUri($this->urlRedecorator->redecorateFromTarget($originalPath)));
 }
Example #5
0
 public function removeAliases($originalPath)
 {
     $this->innerAliasCleaner->removeAliases($this->urlRedecorator->redecorateFromTarget($originalPath));
 }
Example #6
0
 public function removeAliases($originalPath)
 {
     $this->innerAliasCleaner->removeAliases($this->ioService->getExternalPath($originalPath));
 }