示例#1
0
 /**
  * @param FilterInterface $filter
  * @throws \InvalidArgumentException
  */
 public function addFilter(FilterInterface $filter)
 {
     $name = $filter->getUniqueKey();
     if ($this->hasFilter($name)) {
         throw new \InvalidArgumentException(sprintf('Filter %s is already loaded.', $name));
     }
     $this->filters[$name] = $filter;
 }
 public function getFilteredImagePath(ImageInterface $image, FilterInterface $filter)
 {
     $cachePath = $this->cacheRoot . '/' . $filter->getUniqueKey() . '/' . $image->getHash() . '.' . $image->getExtension();
     if (!is_file($cachePath)) {
         $dir = dirname($cachePath);
         if (!is_dir($dir)) {
             mkdir($dir, 0777, true);
         }
         $filter->apply($this->imagine->open($image->getAbsolutePath()))->save($cachePath);
     }
     return $cachePath;
 }