ImageHandler.php 672B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Gregwar\ImageBundle;
  3. use Gregwar\ImageBundle\Image;
  4. /**
  5. * Image manipulation class
  6. *
  7. * @author Gregwar <g.passault@gmail.com>
  8. */
  9. class ImageHandler extends Image
  10. {
  11. protected $fileCallback = null;
  12. /**
  13. * Defines the callback to call to compute the new filename
  14. */
  15. public function setFileCallback($file)
  16. {
  17. $this->fileCallback = $file;
  18. }
  19. /**
  20. * When processing the filename, call the callback
  21. */
  22. protected function getFilename($filename)
  23. {
  24. $callback = $this->fileCallback;
  25. if (null === $callback)
  26. return $filename;
  27. return $callback($filename);
  28. }
  29. }