‪TYPO3CMS  10.4
StripTagsViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic;
21 
72 class ‪StripTagsViewHelper extends AbstractViewHelper
73 {
74  use CompileWithContentArgumentAndRenderStatic;
75 
81  protected ‪$escapeOutput = false;
82 
88  public function ‪initializeArguments()
89  {
90  $this->registerArgument('value', 'string', 'string to format');
91  $this->registerArgument('allowedTags', 'string', 'Optional string of allowed tags as required by PHPs strip_tags() f
92 unction');
93  }
94 
100  protected ‪$escapeChildren = false;
101 
111  public static function ‪renderStatic(
112  array $arguments,
113  \Closure $renderChildrenClosure,
114  RenderingContextInterface $renderingContext
115  ) {
116  $value = $renderChildrenClosure();
117  $allowedTags = $arguments['allowedTags'];
118  if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) {
119  return $value;
120  }
121  return strip_tags((string)$value, $allowedTags);
122  }
123 }
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper\$escapeChildren
‪bool $escapeChildren
Definition: StripTagsViewHelper.php:97
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper
Definition: StripTagsViewHelper.php:73
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: StripTagsViewHelper.php:108
‪TYPO3\CMS\Fluid\ViewHelpers\Format
Definition: AbstractEncodingViewHelper.php:16
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper\initializeArguments
‪initializeArguments()
Definition: StripTagsViewHelper.php:86
‪TYPO3\CMS\Fluid\ViewHelpers\Format\StripTagsViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: StripTagsViewHelper.php:79