Epic #73121
closed
Render() method arguments should be moved to initializeArguments()
Added by Claus Due almost 9 years ago.
Updated about 7 years ago.
Estimated time:
(Total: 0.00 h)
Description
To prevent any errors with PHP7 and subclassed ViewHelpers if/when render() method signatures change. Moving the argument registrations away from the render() method means the render() method signature will never change, making it safe to subclass. Medium complexity due to size of code base needing changes.
- Status changed from New to Needs Feedback
Imho subclassing view helpers is an anti pattern.
VHs should not be open for subclassing and should be considered final.
If we have shared functionality, this should be encapsuled in a classed and composition should be used in the VHs in question to pull this functionality in.
See ImageViewHelper as an example.
To be clear: I would support to introduce the requirement to use `initializeArguments()` but for other reasons:
We can add the render method and the initializeArguments methods to the interface with the following benefits:
- Clearer API (only one style to do things)
- It is a much clearer contract for VH authors
- It reduces runtime magic resoliving
To make this reality the following things need to be done:
- Change all core VHs
- Deprecate render methods with arguments (with target for removal in 9)
There are other benefits than being able to subclass the ViewHelpers. For example, avoiding the reflection framework and becoming a better Fluid citizen (not requiring special execution handling to support render method arguments).
As such, the topic of this discussion should not be "should be allow subclassing ViewHelpers" but rather "should we move argument registrations to avoid reflection and executions only supported on TYPO3 CMS". Whether or not we should even allow subclassing ViewHelpers should be another discussion.
To make this reality the following things need to be done:
Yes, that is what I intend to do.
I would like to add here that we can actually scrap the render() method completely. It's not needed. If renderStatic exists, and it always does, that method can be called directly.
- Target version set to 8.0
- Status changed from Needs Feedback to New
- Target version changed from 8.0 to 8 LTS
- Tracker changed from Bug to Epic
- Status changed from New to Resolved
- Status changed from Resolved to Closed
Also available in: Atom
PDF