Last active
October 18, 2015 16:58
-
-
Save derhansen/462dc7766293e82b17df to your computer and use it in GitHub Desktop.
Renders a TYPO3 Fluid StandaloneView respecting the given language. Can be used from the TYPO3 backend context (e.g. scheduler task)
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
| /** | |
| * Renders a Fluid StandaloneView respecting the given language | |
| * | |
| * @param string $language The language (e.g. de, dk or se) | |
| * @return string | |
| * @throws \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException | |
| */ | |
| public function renderStandaloneView($language = '') { | |
| if ($language !== '') { | |
| // Temporary set Language of current BE user to given language | |
| $GLOBALS['BE_USER']->uc['lang'] = $language; | |
| } | |
| /** @var \TYPO3\CMS\Fluid\View\StandaloneView $view */ | |
| $view = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView'); | |
| $view->setFormat('html'); | |
| $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); | |
| $templateRootPath = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['plugin.']['tx_standaloneview.']['view.']['templateRootPath']); | |
| $view->setTemplatePathAndFilename($templateRootPath . 'StandaloneView.html'); | |
| // Set Extension name, so localizations for extension get respected | |
| $extensionKey = 'standaloneview'; | |
| $view->getRequest()->setControllerExtensionName(GeneralUtility::underscoredToUpperCamelCase($extensionKey)); | |
| return $view->render(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment