Text as file response for Nette Framework
Installation via Composer.
{
"require":{
"joseki/text-as-file-response": "@dev"
}
}
// in a Presenter
public function actionDownload()
{
$template = $this->createTemplate();
$template->setFile("/path/to/template.latte");
$template->someValue = 123;
$response = new Joseki\Application\Responses\TextAsFileResponse($template, 'MyFilename.txt');
$this->sendResponse($response);
}
// in a Presenter
public function actionDownload()
{
$data = 'lorem ipsum...';
$response = new Joseki\Application\Responses\TextAsFileResponse($data, 'MyFilename.txt');
$this->sendResponse($response);
}
// in a Presenter
public function actionDownload()
{
$response = new Joseki\Application\Responses\TextAsFileResponse($data, 'MyFilename.xml', 'application/xml');
$this->sendResponse($response);
}