Exemple #1
0
 /**
  * @param ImageTool                $imageTool
  * @param MediaCache               $cmsMediaCache
  * @param DynamicCreatorMediaCache $mediaCache
  * @param MediaInfoStorageItem     $mediaItem
  * @param string                   $cdnType
  * @param array                    $operations
  */
 protected function createMediaCacheFile(ImageTool $imageTool, MediaCache $cmsMediaCache, DynamicCreatorMediaCache $mediaCache, MediaInfoStorageItem $mediaItem, $cdnType, array $operations)
 {
     if (count($operations) <= 0) {
         return;
     }
     $isIcon = false;
     switch ($cdnType) {
         case MediaRequest::TYPE_IMAGE:
             $filePath = $mediaItem->getFilePath();
             break;
         case MediaRequest::TYPE_ICON:
             $isIcon = true;
             $filePath = $mediaItem->getIconFilePath();
             break;
         case MediaRequest::TYPE_PREVIEW:
             $filePath = $mediaItem->getFilePath();
             if (!$imageTool->isImageFile($filePath)) {
                 $isIcon = true;
                 $filePath = $mediaItem->getIconFilePath();
             }
             break;
         default:
             return;
     }
     $cmsCacheFilePath = $this->createCmsCacheFile($imageTool, $cmsMediaCache, $mediaItem, $operations, $isIcon, $filePath);
     $liveCacheFilePath = $mediaCache->getCacheFilePath($mediaItem, $operations, $isIcon);
     FS::copyFile($cmsCacheFilePath, $liveCacheFilePath);
 }
Exemple #2
0
 /**
  * @param MediaInfoStorageItem $mediaItem
  * @param                      $useIcon
  *
  * @return string
  */
 private function getBaseFilenameForCache(MediaInfoStorageItem $mediaItem, $useIcon)
 {
     if ($useIcon) {
         return basename($mediaItem->getIconFilePath());
     } else {
         $extension = $this->getExtensionFromFilename(basename($mediaItem->getFilePath()));
         return $mediaItem->getId() . '.' . $extension;
     }
 }