-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathRenderMessageViewHelper.php
40 lines (34 loc) · 1.01 KB
/
RenderMessageViewHelper.php
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
<?php
declare(strict_types = 1);
namespace Kitzberger\FormMailtext\ViewHelpers;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface;
class RenderMessageViewHelper extends AbstractViewHelper
{
/**
* @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)
*
* @return string the rendered form values
*/
public function render()
{
$message = $this->arguments['message'];
// replace {variables} by the child content of this viewhelper
$message = preg_replace('/(<p>)?{variables}(<\/p>)?/', $this->renderChildren(), $message);
return $message;
}
}