From e6297563b3d1e55c08f5d752a3ae272bebf2ce25 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Sat, 14 Apr 2012 04:56:59 +0200 Subject: [PATCH] Throwing an error if source image doesn't exist --- Imagine/Data/Loader/FileSystemLoader.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Imagine/Data/Loader/FileSystemLoader.php b/Imagine/Data/Loader/FileSystemLoader.php index b2b6bd872..641540586 100644 --- a/Imagine/Data/Loader/FileSystemLoader.php +++ b/Imagine/Data/Loader/FileSystemLoader.php @@ -47,6 +47,10 @@ public function __construct(ImagineInterface $imagine, $formats, $rootPath) */ protected function getFileInfo($absolutePath) { + if (!file_exists($absolutePath)) { + throw new NotFoundHttpException(sprintf("Source image '%s' doesn't exist", $absolutePath)); + } + return pathinfo($absolutePath); } @@ -61,7 +65,8 @@ public function find($path) throw new NotFoundHttpException(sprintf("Source image was searched with '%s' out side of the defined root path", $path)); } - $info = $this->getFileInfo($this->rootPath.'/'.ltrim($path, '/')); + $file = $this->rootPath.'/'.ltrim($path, '/'); + $info = $this->getFileInfo($file); $absolutePath = $info['dirname'].'/'.$info['basename']; $name = $info['dirname'].'/'.$info['filename'];