Skip to content
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

Add ViewModel::addChild(...) support #87

Open
pmattmann opened this issue Mar 5, 2014 · 1 comment
Open

Add ViewModel::addChild(...) support #87

pmattmann opened this issue Mar 5, 2014 · 1 comment

Comments

@pmattmann
Copy link

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...

@spiffyjr
Copy link
Contributor

spiffyjr commented Mar 7, 2014

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.

kusmierz added a commit to kusmierz/ZfcTwig that referenced this issue May 19, 2016
kokspflanze added a commit to kokspflanze/ZfcTwig that referenced this issue May 26, 2017
kokspflanze pushed a commit to kokspflanze/ZfcTwig that referenced this issue May 30, 2017
…dChild support

(cherry picked from commit eaf04e7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants