TYPO3 CMS  TYPO3_7-6
HtmlViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is part of the TYPO3 project - inspiring people to share! *
6  * *
7  * TYPO3 is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU General Public License version 2 as published by *
9  * the Free Software Foundation. *
10  * *
11  * This script is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
14  * Public License for more details. *
15  * */
16 
24 
57 {
61  protected static $tsfeBackup;
62 
70  protected $escapingInterceptorEnabled = false;
71 
76  public function render($parseFuncTSPath = 'lib.parseFunc_RTE')
77  {
78  return static::renderStatic(
79  [
80  'parseFuncTSPath' => $parseFuncTSPath,
81  ],
83  $this->renderingContext
84  );
85  }
86 
95  {
96  $parseFuncTSPath = $arguments['parseFuncTSPath'];
97  if (TYPO3_MODE === 'BE') {
98  self::simulateFrontendEnvironment();
99  }
100  $value = $renderChildrenClosure();
101  $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
102  $contentObject->start([]);
103  $content = $contentObject->parseFunc($value, [], '< ' . $parseFuncTSPath);
104  if (TYPO3_MODE === 'BE') {
105  self::resetFrontendEnvironment();
106  }
107  return $content;
108  }
109 
116  protected static function simulateFrontendEnvironment()
117  {
118  self::$tsfeBackup = isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : null;
119  $GLOBALS['TSFE'] = new \stdClass();
120  $GLOBALS['TSFE']->tmpl = new \stdClass();
121  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
122  $configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
123  $GLOBALS['TSFE']->tmpl->setup = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
124  }
125 
132  protected static function resetFrontendEnvironment()
133  {
134  $GLOBALS['TSFE'] = self::$tsfeBackup;
135  }
136 }
render($parseFuncTSPath='lib.parseFunc_RTE')
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']