Skip to content

Instantly share code, notes, and snippets.

@kitsunet
Created August 1, 2012 14:51
Show Gist options
  • Select an option

  • Save kitsunet/3227502 to your computer and use it in GitHub Desktop.

Select an option

Save kitsunet/3227502 to your computer and use it in GitHub Desktop.
Using different view depending on format
<?
class MyController extends ActionController {
protected $viewFormatToObjectNameMap = array(
'pdf' => '\TYPO3\TcPdf\View\HtmlPdfView'
);
/**
* @return void
*/
public function initializeIndexAction() {
switch ($this->request->getFormat()) {
case 'pdf':
$this->response->setHeader('Content-Type', 'application/pdf', $replaceExistingHeader = TRUE);
$this->response->setHeader('Cache-Control', 'public, must-revalidate, max-age=0', $replaceExistingHeader = TRUE);
$this->response->setHeader('Content-disposition', 'attachment;filename=export.pdf', $replaceExistingHeader = TRUE);
break;
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment