typo3typo3-8.xview-helperstypo3-9.x

How to rework TYPO3 8 AbstractViewHelper for TYPO3 9.5


We have a class called AmazMenu.php which extends from the class AbstractViewHelper. It does some stuff on 600 lines of code but now the Baseclass got removed. it is a documented breaking change but I can't figure out what approach to use from now on and how to refactor the class used stuff like:

public function initializeArguments()
private function recursiveTree($tree, $maxDepth = 0, $depth = 0, $parentIsActive = false)
private function renderTree()
public function render()

Because I guess if the Baseclass gets removed also the directory ViewHelpers is gone - so the logic handled by our ViewHelper has to get implemented somewhere else - but where and by what concept?

Help is much appreciated.


Solution

  • You could try to use the AbstractClass of the template engine: TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper instead. That's the change for TYPO3 itself in most cases as you can see here: https://review.typo3.org/c/Packages/TYPO3.CMS/+/54946/4/typo3/sysext/backend/Classes/ViewHelpers/AvatarViewHelper.php

    Also follow the migration steps, don't use the render() method anymore, but use renderStatic(). This is also documented here: https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/8-Fluid/8-developing-a-custom-viewhelper.html#renderstatic-method