Skip to content

Commit

Permalink
[TASK] Add base Widget class methods for Fluid 3.0 compat
Browse files Browse the repository at this point in the history
Adds two new methods, evaluate() and onClose() which
makes Widgets compatible with Fluid 3.0 but which are
never called on Fluid 2.x.

Releases: master, 9.5, 8.7
Resolves: #90286
Change-Id: I36a99c30e7c3bb5baae065cfc6368a2bf493cc40
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63133
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63247
Tested-by: Claus Due <claus@phpmind.net>
Reviewed-by: Claus Due <claus@phpmind.net>
  • Loading branch information
NamelessCoder committed Feb 15, 2020
1 parent b6c3a09 commit 79bd294
Showing 1 changed file with 34 additions and 0 deletions.
Expand Up @@ -14,8 +14,10 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3Fluid\Fluid\Component\ComponentInterface;
use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler;
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;

/**
* @api
Expand Down Expand Up @@ -116,6 +118,38 @@ public function initializeArgumentsAndRender()
return $this->callRenderMethod();
}

/**
* Initialize the arguments of the ViewHelper, and call the render() method of the ViewHelper.
*
* @param RenderingContextInterface $renderingContext
* @return string the rendered ViewHelper.
* @internal
*/
public function evaluate(RenderingContextInterface $renderingContext)
{
$this->renderingContext = $renderingContext;
$this->getArguments()->setRenderingContext($renderingContext);
$this->initializeWidgetContext();
return $this->callRenderMethod();
}

/**
* Stores the syntax tree child nodes in the Widget Context, so they can be
* rendered with <f:widget.renderChildren> lateron.
*
* @param RenderingContextInterface $renderingContext
* @return ComponentInterface
* @internal
*/
public function onClose(RenderingContextInterface $renderingContext): ComponentInterface
{
$node = parent::onClose($renderingContext);
$rootNode = $this->objectManager->get(\TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\RootNode::class);
$rootNode->setChildren($this->getChildren());
$this->widgetContext->setViewHelperChildNodes($rootNode, $renderingContext);
return $node;
}

/**
* Initialize the Widget Context, before the Render method is called.
*/
Expand Down

0 comments on commit 79bd294

Please sign in to comment.