You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, ZfcTwig does not support TreeRendering.
Is there a good reason for this? What is the Twig-Way to handle ViewModel-Trees?
I tried to check the current implementation and I think I have detected the main problem. In the class Zend\Mvc\View\Http\InjectViewModelListener Zend builds usually a mini-tree where the controller response gets wrapped with the layout.
This is not helpful, as Twig handles layouts by deriving templates.
I see different ways to handle this problem and so to add support for TreeRendering:
detach the Zend\Mvc\View\Http\InjectViewModelListener
add a default and empty layout (requires view_manager config and a twig-file)
add a EventListener before Zend\Mvc\View\Http\InjectViewModelListener and call setTerminal(true) on ViewModel in the MvcEvent::result
After implementing one of these 3 ideas, one could then change the TwigRenderer to not return in the foreach loop over all children, but one could then call the rendering-method recursively and store the rendering result in the $values of the parent ViewModel.
Personally, I would prefer the second idea.
I expect that idea to be the most forward compatible of all of them.
What do you think?
Would you accept a pull request going in that direction?
Regards, Pirmin
PS. Sorry for the poor english - i hope, you get the idea...
The text was updated successfully, but these errors were encountered:
I tried to handle this and actually attempted it in a few of the methods you presented and the issue is providing proper support for both phtml (used in modules) and twig files without breaking one or the other. If you can submit a PR that clearly defines what you're trying to accomplish as well as an example/use-case that would help.
At the moment, ZfcTwig does not support TreeRendering.
Is there a good reason for this? What is the Twig-Way to handle ViewModel-Trees?
I tried to check the current implementation and I think I have detected the main problem. In the class Zend\Mvc\View\Http\InjectViewModelListener Zend builds usually a mini-tree where the controller response gets wrapped with the layout.
This is not helpful, as Twig handles layouts by deriving templates.
I see different ways to handle this problem and so to add support for TreeRendering:
After implementing one of these 3 ideas, one could then change the TwigRenderer to not return in the foreach loop over all children, but one could then call the rendering-method recursively and store the rendering result in the $values of the parent ViewModel.
Personally, I would prefer the second idea.
I expect that idea to be the most forward compatible of all of them.
What do you think?
Would you accept a pull request going in that direction?
Regards, Pirmin
PS. Sorry for the poor english - i hope, you get the idea...
The text was updated successfully, but these errors were encountered: