[BUGFIX] Wording 78169-IntroduceTranslationSourceFieldForTt_content.rst
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / Core / ViewHelper / AbstractConditionViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Core\ViewHelper;
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
17 /**
18 * Class AbstractConditionViewHelper
19 */
20 abstract class AbstractConditionViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper
21 {
22 /**
23 * Controller Context to use
24 *
25 * @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
26 * @api
27 */
28 protected $controllerContext;
29
30 /**
31 * Renders <f:then> child if $condition is true, otherwise renders <f:else> child.
32 *
33 * @param bool $condition View helper condition
34 * @return string the rendered string
35 * @api
36 */
37 public function render()
38 {
39 if (static::evaluateCondition($this->arguments)) {
40 return $this->renderThenChild();
41 }
42 return $this->renderElseChild();
43 }
44
45 /**
46 * @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
47 */
48 public function setRenderingContext(\TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
49 {
50 parent::setRenderingContext($renderingContext);
51 if ($renderingContext instanceof \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext) {
52 $this->controllerContext = $renderingContext->getControllerContext();
53 }
54 }
55 }