TYPO3 CMS  TYPO3_8-7
HtmlViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
24 
57 {
59 
63  protected static $tsfeBackup;
64 
70  protected $escapeChildren = false;
71 
77  protected $escapeOutput = false;
78 
84  public function initializeArguments()
85  {
86  parent::initializeArguments();
87  $this->registerArgument('parseFuncTSPath', 'string', ' path to TypoScript parseFunc setup.', false, 'lib.parseFunc_RTE');
88  }
89 
97  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
98  {
99  $parseFuncTSPath = $arguments['parseFuncTSPath'];
100  if (TYPO3_MODE === 'BE') {
101  self::simulateFrontendEnvironment();
102  }
103  $value = $renderChildrenClosure();
104  $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
105  $contentObject->start([]);
106  $content = $contentObject->parseFunc($value, [], '< ' . $parseFuncTSPath);
107  if (TYPO3_MODE === 'BE') {
108  self::resetFrontendEnvironment();
109  }
110  return $content;
111  }
112 
117  protected static function simulateFrontendEnvironment()
118  {
119  self::$tsfeBackup = isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : null;
120  $GLOBALS['TSFE'] = new \stdClass();
121  $GLOBALS['TSFE']->tmpl = new \stdClass();
122  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
123  $configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
124  $GLOBALS['TSFE']->tmpl->setup = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
125  }
126 
132  protected static function resetFrontendEnvironment()
133  {
134  $GLOBALS['TSFE'] = self::$tsfeBackup;
135  }
136 }
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']