Created
August 1, 2012 14:51
-
-
Save kitsunet/3227502 to your computer and use it in GitHub Desktop.
Using different view depending on format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| 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