Created
January 31, 2017 17:31
-
-
Save smichaelsen/bb042731c4bf7852e416f2cf823dd4fb to your computer and use it in GitHub Desktop.
Workaround for flux bug #1308
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
<?php | |
namespace MyVendor\MyExtension\Controller; | |
use FluidTYPO3\Flux\Utility\ExtensionNamingUtility; | |
use FluidTYPO3\Flux\Utility\RecursiveArrayUtility; | |
use FluidTYPO3\Flux\View\TemplatePaths; | |
use TYPO3\CMS\Core\Utility\GeneralUtility; | |
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; | |
class ContentController extends \FluidTYPO3\Flux\Controller\ContentController | |
{ | |
/** | |
* @var \FluidTYPO3\Flux\View\ExposedTemplateView | |
*/ | |
protected $view; | |
/** | |
* Workaround for https://github.com/FluidTYPO3/flux/issues/1308 | |
* The plugin view settings will be read from TypoScript again and the TemplatePaths of the view will be set | |
* accordingly. | |
* | |
* @param ViewInterface $view | |
*/ | |
public function initializeView(ViewInterface $view) | |
{ | |
parent::initializeView($view); | |
$extensionName = 'NaturataProducts'; | |
$extensionKey = ExtensionNamingUtility::getExtensionKey($extensionName); | |
$defaults = [ | |
TemplatePaths::CONFIG_TEMPLATEROOTPATHS => [0 => 'EXT:' . $extensionKey . '/Resources/Private/Templates/'], | |
TemplatePaths::CONFIG_PARTIALROOTPATHS => [0 => 'EXT:' . $extensionKey . '/Resources/Private/Partials/'], | |
TemplatePaths::CONFIG_LAYOUTROOTPATHS => [0 => 'EXT:' . $extensionKey . '/Resources/Private/Layouts/'], | |
]; | |
$signature = ExtensionNamingUtility::getExtensionSignature($extensionName); | |
$configuration = (array) $this->configurationService->getTypoScriptByPath('plugin.tx_' . $signature . '.view'); | |
$viewConfiguration = RecursiveArrayUtility::mergeRecursiveOverrule($defaults, $configuration); | |
// for whatever reason manipulating $view doesn't do the trick here, so we work on $this->view. | |
// But hey, we're in a dirty workaround anyway. | |
$this->view->setTemplatePaths(new TemplatePaths($viewConfiguration)); | |
} | |
// ... the rest of your ContentController | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment