bug #10797 [HttpFoundation] Allow File instance to be passed to BinaryFileResponse (anlutro)
This PR was merged into the 2.3 branch.
Discussion
----------
[HttpFoundation] Allow File instance to be passed to BinaryFileResponse
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #10608
| License | MIT
| Doc PR |
See https://github.com/symfony/symfony/issues/10608 for discussion and reasoning.
The docblocks get rather long with this change. The File class does extend SplFileObject so technically it could be left out of the docblock if that is more desirable.
Commits
-------
fc04ad2
Allow File instance to be passed to BinaryFileResponse
This commit is contained in:
commit
9e2a834582
@ -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)
|
||||||
{
|
{
|
||||||
|
if (!$file instanceof File) {
|
||||||
$file = new File((string) $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.');
|
||||||
|
Reference in New Issue
Block a user