TYPO3  7.6
HtmlViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
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  array(
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  $content = $contentObject->parseFunc($value, array(), '< ' . $parseFuncTSPath);
103  if (TYPO3_MODE === 'BE') {
104  self::resetFrontendEnvironment();
105  }
106  return $content;
107  }
108 
115  protected static function simulateFrontendEnvironment()
116  {
117  self::$tsfeBackup = isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : null;
118  $GLOBALS['TSFE'] = new \stdClass();
119  $GLOBALS['TSFE']->tmpl = new \stdClass();
120  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
121  $configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
122  $GLOBALS['TSFE']->tmpl->setup = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
123  }
124 
131  protected static function resetFrontendEnvironment()
132  {
133  $GLOBALS['TSFE'] = self::$tsfeBackup;
134  }
135 }