Story #73183
closedRemoval of frontend simulation in all ViewHelpers
0%
Description
This issue is to remind of and discuss the following opinionated argument:
"No ViewHelpers should themselves simulate any part of the frontend. Instead, they should throw exceptions if detecting an incomplete frontend context (TSFE, etc.)"
The argument goes as follows:
- There is no utility currently which allows perfectly simulating the frontend
- The only way to simulate the frontend from a ViewHelper is to set up and construct the fake on every execution
- Simulation can be very expensive and is only necessary in some use cases
- Frontend simulation should be opt-in and a conscious decision from the developer (dev should be in control of it)
Rather than perform obscured frontend simulations each ViewHelper can instead simply verify the environment it needs and throw a special exception if one isn't found, informing the developer to simulate the frontend before he renders his View and tear it down once he is done rendering.
In terms of performance another solution exists. It would be even simpler to assume that a proper frontend is simulated and throw whichever error happens to occur, e.g. "undefined variable", "call to undefined method" etc. and clearly document in each ViewHelper's documentation block (not in code) what it requires of the frontend context. The argument being that we don't necessarily have to carefully handle every conceivable context problem as long as we inform that "this ViewHelper requires a frontend context minimally consisting of a TSFE with a page repository" and expect the developer to know what that implies if he wants to use that ViewHelper in the backend.