Skip to content

Instantly share code, notes, and snippets.

@kj187
Created February 25, 2014 08:34
Show Gist options
  • Save kj187/9205103 to your computer and use it in GitHub Desktop.
Save kj187/9205103 to your computer and use it in GitHub Desktop.
StandaloneView
#Step 1:
$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$this->configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
#Step 2:
Call $this->getStandaloneView(array('job' => $job), 'Pdf/Email.html')->render();
/**
* @param array $store
* @return string
*/
protected function getStandaloneView(array $variables, $template) {
$viewObject = $this->objectManager->create('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$viewObject->setFormat('html');
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$templateRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']);
$templatePathAndFilename = $templateRootPath . $template;
$viewObject->setTemplatePathAndFilename($templatePathAndFilename);
$viewObject->assignMultiple($variables);
return $viewObject;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment