‪TYPO3CMS  9.5
StripTagsViewHelper.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 
17 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
18 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic;
20 
71 class ‪StripTagsViewHelper extends AbstractViewHelper
72 {
73  use CompileWithContentArgumentAndRenderStatic;
74 
80  protected ‪$escapeOutput = false;
81 
87  public function ‪initializeArguments()
88  {
89  $this->registerArgument('value', 'string', 'string to format');
90  $this->registerArgument('allowedTags', 'string', 'Optional string of allowed tags as required by PHPs strip_tags() f
91 unction');
92  }
93 
99  protected ‪$escapeChildren = false;
100 
110  public static function ‪renderStatic(
111  array $arguments,
112  \Closure $renderChildrenClosure,
113  RenderingContextInterface $renderingContext
114  ) {
115  $value = $renderChildrenClosure();
116  $allowedTags = $arguments['allowedTags'];
117  if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) {
118  return $value;
119  }
120  return strip_tags((string)$value, $allowedTags);
121  }
122 }
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper\$escapeChildren
‪bool $escapeChildren
Definition: StripTagsViewHelper.php:96
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper
Definition: StripTagsViewHelper.php:72
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: StripTagsViewHelper.php:107
‪TYPO3\CMS\Fluid\ViewHelpers\Format
Definition: AbstractEncodingViewHelper.php:2
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper\initializeArguments
‪initializeArguments()
Definition: StripTagsViewHelper.php:85
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: StripTagsViewHelper.php:78