Allow File instance to be passed to BinaryFileResponse

This commit is contained in:
Andreas Lutro 2014-04-28 14:17:03 +02:00
parent 37a4876d8b
commit fc04ad2134
1 changed files with 3 additions and 1 deletions

View File

@ -81,7 +81,9 @@ class BinaryFileResponse extends Response
*/ */
public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
{ {
$file = new File((string) $file); if (!$file instanceof File) {
$file = new File((string) $file);
}
if (!$file->isReadable()) { if (!$file->isReadable()) {
throw new FileException('File must be readable.'); throw new FileException('File must be readable.');