Project

General

Profile

Actions

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 3 days ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
Start date:
2021-11-23
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
easy
Sprint Focus:

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;

}
Actions #1

Updated by Heiko Dietrich over 2 years ago

  • 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;

}

Actions #2

Updated by Georg Ringer 3 days ago

  • Description updated (diff)
Actions #3

Updated by Georg Ringer 3 days ago

  • 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

Actions

Also available in: Atom PDF