-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZendView 3: Rendering engine simplification #30
Comments
It is possible to remove the magic get/set methods for variables? They are slow and people are forced to check if variables are set. Could avoid Bugs. Another point is the PHPDoc block for variables in the view script, so code completion is available. This reduces the complexity too. Originally posted by @sandrokeil at zendframework/zend-view#19 (comment) |
It would be nice if the ViewManager or View would support rendering outside the MVC lifecycle e.g. for rendering the body of a mail. Best way I know currently is to set Originally posted by @hoppithek at zendframework/zend-view#19 (comment) |
Seeing that work on ServiceManager and EventManager is progressing, I'd like to start discussing new
Zend\View
.My goals are to:
As a first step, I prepared a proposal for rendering mechanism.
Responsibility issue
A this moment, rendering nested view models happens in two places (I'm skipping console for simplicity):
Zend\View
, when renderingphtml
templates (other renderers can be used here as well)JsonRenderer
, when renderingJsonModel
sHere's how rendering is done now within application flow:
Basically, right now different layers are responsible for the same thing.
I suggest to make it look like this:
New listener (JsonRendererStrategy) would be replacing JsonStrategy. It would be attached to the same events as DefaultRenderingStrategy. This fixes responsibility problem, while keeping amlost full compatibility with typical application. Only thing to update would be a requirement to register JsonRenderingStrategy somewhere else within the config. Perhaps we should also consider different naming: we have a concept of "Strategy" related to different layers.
With this approach, whole system can be simplified (I also listed simplifications that are not related to this issue):
RendererInterface
getEngine() appears not to be used anywhere - it can be removed.
setResolver()
can be also removed, and resolver can be injected via constructorideally renderers would only render ViewModels (it shouldn't accept template names), but this may be too big BC break. So, I suggest following signature:
TreeRendererInterface
PhpRenderer
addTemplate
method can be removed as well (I don't see it being needed anywhere)I have more ideas for Zend\View class and helper system, but I'd like to see where this goes first (other proposals will depend on this one). Does it make sense? If yes, I can start working on prototype implementation.
Originally posted by @mtymek at zendframework/zend-view#19
The text was updated successfully, but these errors were encountered: