TYPO3 CMS  TYPO3_8-7
RenderRenderableViewHelper.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It originated from the Neos.Form package (www.neos.io)
9  *
10  * It is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License, either version 2
12  * of the License, or any later version.
13  *
14  * For the full copyright and license information, please read the
15  * LICENSE.txt file that was distributed with this source code.
16  *
17  * The TYPO3 project - inspiring people to share!
18  */
19 
27 
38 {
40 
44  protected $escapeOutput = false;
45 
51  public function initializeArguments()
52  {
53  parent::initializeArguments();
54  $this->registerArgument('renderable', RootRenderableInterface::class, 'A RenderableInterface instance', true);
55  }
56 
64  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
65  {
66 
68  $formRuntime = $renderingContext
69  ->getViewHelperVariableContainer()
70  ->get(self::class, 'formRuntime');
71 
72  GeneralUtility::deprecationLog('EXT:form - calls for "beforeRendering" are deprecated since TYPO3 v8 and will be removed in TYPO3 v9');
73  $arguments['renderable']->beforeRendering($formRuntime);
74 
75  if (
76  isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'])
77  && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'])
78  ) {
79  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'] as $className) {
80  $hookObj = GeneralUtility::makeInstance($className);
81  if (method_exists($hookObj, 'beforeRendering')) {
82  $hookObj->beforeRendering(
83  $formRuntime,
84  $arguments['renderable']
85  );
86  }
87  }
88  }
89 
90  $content = $renderChildrenClosure();
91 
92  // Wrap every renderable with a span with a identifier path data attribute if previewMode is active
93  if (!empty($content)) {
94  $renderingOptions = $formRuntime->getRenderingOptions();
95  if (isset($renderingOptions['previewMode']) && $renderingOptions['previewMode'] === true) {
96  $renderable = $arguments['renderable'];
97  $path = $renderable->getIdentifier();
98  if ($renderable instanceof RenderableInterface) {
99  while ($renderable = $renderable->getParentRenderable()) {
100  $path = $renderable->getIdentifier() . '/' . $path;
101  }
102  }
103  $content = '<span data-element-identifier-path="' . $path . '">' . $content . '</span>';
104  }
105  }
106  return $content;
107  }
108 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']