/** * @param FileObject $file * @param Response $response */ protected function injectContentToResponse(FileObject $file, Response $response) { $response->setContent(function () use($file) { return file_get_contents($file->getRealPath()); }); }
/** * Deletes on destruct if temporary */ public function __destruct() { if ($this->isTemporary()) { unlink($this->fileObject->getRealPath()); } }