Feature #96061
closed
Please define RendererResolver-Class in an static Member in \TYPO3\CMS\Fluid\ViewHelpers\FlashMessagesViewHelper like Description
Added by Heiko Dietrich over 2 years ago.
Updated 2 months ago.
Description
Please define RendererResolver in an static Member (in Example $rendererResolverClassName) in \TYPO3\CMS\Fluid\ViewHelpers\FlashMessagesViewHelper like Description
So is it easier to extend the Viewhelper and change the RendererResolver-Class
class FlashMessagesViewHelper
{
// New Ststic Member for RendererResolver
protected static $rendererResolverClassName = TYPO3\CMS\Core\Messaging\FlashMessageRendererResolver::class;
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(static::$rendererResolverClassName)
->resolve()
->render($flashMessages);
}
$templateVariableContainer = $renderingContext->getVariableProvider();
$templateVariableContainer->add($as, $flashMessages);
$content = $renderChildrenClosure();
$templateVariableContainer->remove($as);
return $content;
}
.....
}
class OwnFlashMessagesViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FlashMessagesViewHelper
{
protected static $rendererResolverClassName = OwnFlashMessageRendererResolver::class;
}
- Subject changed from Please define RendererResolver in an static Member in \TYPO3\CMS\Fluid\ViewHelpers\FlashMessagesViewHelper like Description to Please define RendererResolver-Class in an static Member in \TYPO3\CMS\Fluid\ViewHelpers\FlashMessagesViewHelper like Description
Please define RendererResolver-Class in an static Member (in Example $rendererResolverClassName) in \TYPO3\CMS\Fluid\ViewHelpers\FlashMessagesViewHelper
class FlashMessagesViewHelper {
// New Static Member for RendererResolver
protected static $rendererResolverClassName = TYPO3\CMS\Core\Messaging\FlashMessageRendererResolver::class;
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(static::$rendererResolverClassName)
->resolve()
->render($flashMessages);
}
$templateVariableContainer = $renderingContext->getVariableProvider();
$templateVariableContainer->add($as, $flashMessages);
$content = $renderChildrenClosure();
$templateVariableContainer->remove($as);
return $content;
}
.....
}
So is it easier to extend the Viewhelper and change the RendererResolver-Class to an own Class
class OwnFlashMessagesViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FlashMessagesViewHelper {
protected static $rendererResolverClassName = OwnFlashMessageRendererResolver::class;
}
- Description updated (diff)
- Status changed from New to Rejected
as all viewhelpers have been defined as final ut is not possible anymore to extend them anymore - therefore closing the issue
Also available in: Atom
PDF