Example #1
0
 /**
  * @param ImageTool            $imageTool
  * @param MediaCache           $cmsMediaCache
  * @param MediaInfoStorageItem $mediaItem
  * @param array                $operations
  * @param string               $isIcon
  * @param string               $filePath
  *
  * @return string
  */
 protected function createCmsCacheFile(ImageTool $imageTool, MediaCache $cmsMediaCache, MediaInfoStorageItem $mediaItem, array $operations, $isIcon, $filePath)
 {
     $cmsMediaCache->prepareCache($mediaItem);
     $cmsCacheFilePath = $cmsMediaCache->getCacheFilePath($mediaItem, $operations, $isIcon);
     if ($this->isCmsCacheFileValid($mediaItem, $filePath, $cmsCacheFilePath)) {
         return $cmsCacheFilePath;
     }
     $imageTool->open($filePath);
     $imageTool->modify($operations);
     $imageTool->save($cmsCacheFilePath);
     $imageTool->close();
     return $cmsCacheFilePath;
 }
Example #2
0
 /**
  * @param ImageTool $imageTool
  *
  * @return bool
  */
 protected function writeCacheFile(ImageTool $imageTool)
 {
     if (!$this->isWritingCacheFileAllowed()) {
         return true;
     }
     $this->prepareCache();
     $cacheFilePath = $this->getCacheFilePath();
     if (empty($cacheFilePath)) {
         return false;
     }
     if (!$imageTool->save($cacheFilePath)) {
         return false;
     }
     // important: clear the file state cache to get the right values for file calls
     clearstatcache(true, $cacheFilePath);
     $this->setStreamFilePath($cacheFilePath);
     return true;
 }