-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRenderMessageViewHelper.php
More file actions
46 lines (39 loc) · 1.34 KB
/
RenderMessageViewHelper.php
File metadata and controls
46 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types = 1);
namespace Kitzberger\FormMailtext\ViewHelpers;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface;
class RenderMessageViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
/**
* Initialize the arguments.
*
* @internal
*/
public function initializeArguments()
{
$this->registerArgument('message', 'string', 'The message definied in the plugin', false);
}
/**
* Renders the message (incl. the variables)
*
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string the rendered form values
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$message = $arguments['message'];
// replace {variables} by the child content of this viewhelper
$message = preg_replace('/(<p>)?{variables}(<\/p>)?/', $renderChildrenClosure(), $message);
return $message;
}
}