* * A list of flash messages. * * TYPO3 core style * ---------------- * * :: * * * * Output:: * *
*
*
*
* * * * *
*
*

Info - Title for Info message

*

Message text here.

*
*
*
*
* * Output flash messages as a description list * ------------------------------------------- * * :: * * *
* *
{flashMessage.code}
*
{flashMessage.message}
*
*
*
* * Output:: * *
*
1013
*
Some Warning Message.
*
* * Using a specific queue * ---------------------- * * :: * * */ class FlashMessagesViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; /** * ViewHelper outputs HTML therefore output escaping has to be disabled * * @var bool */ protected $escapeOutput = false; /** * Initialize arguments */ public function initializeArguments() { $this->registerArgument('queueIdentifier', 'string', 'Flash-message queue to use'); $this->registerArgument('as', 'string', 'The name of the current flashMessage variable for rendering inside'); } /** * Renders FlashMessages and flushes the FlashMessage queue * Note: This disables the current page cache in order to prevent FlashMessage output * from being cached. * * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::no_cache * @param array $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext * @return mixed */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { $as = $arguments['as']; $queueIdentifier = $arguments['queueIdentifier'] ?? null; $flashMessages = $renderingContext->getControllerContext() ->getFlashMessageQueue($queueIdentifier)->getAllMessagesAndFlush(); if ($flashMessages === null || count($flashMessages) === 0) { return ''; } if ($as === null) { return GeneralUtility::makeInstance(FlashMessageRendererResolver::class) ->resolve() ->render($flashMessages); } $templateVariableContainer = $renderingContext->getVariableProvider(); $templateVariableContainer->add($as, $flashMessages); $content = $renderChildrenClosure(); $templateVariableContainer->remove($as); return $content; } }