Skip to content

Commit

Permalink
fixed post processors using FileBinary
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierlacot committed Feb 13, 2016
1 parent 708785a commit b763eaa
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Binary/FileBinaryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ interface FileBinaryInterface extends BinaryInterface
* @return string
*/
public function getPath();

/**
* @return boolean
*/
public function unlink();
}
7 changes: 6 additions & 1 deletion Controller/ImagineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,17 @@ public function filterAction(Request $request, $path, $filter)
throw new NotFoundHttpException('Source image could not be found', $e);
}

$outBinary = $this->filterManager->applyFilter($binary, $filter);
$this->cacheManager->store(
$this->filterManager->applyFilter($binary, $filter),
$outBinary,
$path,
$filter,
$resolver
);

if ($outBinary instanceof FileBinaryInterface) {
$outBinary->unlink();
}
}

return new RedirectResponse($this->cacheManager->resolve($path, $filter, $resolver), 301);
Expand Down
2 changes: 0 additions & 2 deletions Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ public function process(BinaryInterface $binary)

$result = new FileBinary($input, $binary->getMimeType(), $binary->getFormat());

unlink($input);

return $result;
}
}
2 changes: 0 additions & 2 deletions Imagine/Filter/PostProcessor/OptiPngPostProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public function process(BinaryInterface $binary)

$result = new FileBinary($input, $binary->getMimeType(), $binary->getFormat());

unlink($input);

return $result;
}
}
8 changes: 8 additions & 0 deletions Model/FileBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ public function getFormat()
{
return $this->format;
}

/**
* @return boolean
*/
public function unlink()
{
return unlink($outBinary->getPath());
}
}

0 comments on commit b763eaa

Please sign in to comment.