ZF-Commons / ZfcTwig

Zend Framework 2 Module that provides a Twig rendering strategy
BSD 3-Clause "New" or "Revised" License
96 stars 55 forks source link

Clarity on disable_zf_model after upgrade from 1.0 to 1.1 #65

Closed lvismer closed 11 years ago

lvismer commented 11 years ago

Hi

I upgraded from 1.0 to 1.1 and wanted to find out if the following should still work with disable_zf_model = true (it did work for me on version 1.0.*)

Inside the controller

public function manageAction()
{
    $clients = $this->forward()->dispatch('App\Controller\Client', array(...));
    $contacts = $this->forward()->dispatch('App\Controller\Contact', array(...));

    $viewModel = new ViewModel()
    return $viewModel
        ->addChild($clients, 'clientWidget')
        ->addChild($contacts, 'contactWidget');
}

and then the view

{% extends 'layout/admin.twig' %}
{% block content %}
<div class="tab-content">
<div class="tab-pane fade active in" id="clients">
{{ clientWidget|raw }}
</div>
<div class="tab-pane fade" id="contacts">
{{ contactWidget|raw }}
</div>
</div>
{% endblock content %}

I know I can convert both the forward calls to viewHelpers but I was just wondering. I do not particularly need them as helpers, but if the behaviour is not supported I'll convert the controller calls to helpers.

Many thanks

spiffyjr commented 11 years ago

I haven't tried using multiple children. The child rendering has to be done manually and I'm probably not handling in the best manner possible.

https://github.com/ZF-Commons/ZfcTwig/blob/master/src/ZfcTwig/View/Renderer/TwigRenderer.php#L205

If you want to try and come up with a better solution feel free to submit a PR or offer suggestions.

lvismer commented 11 years ago

Kyle I added a pull request that addressed my use case.

https://github.com/ZF-Commons/ZfcTwig/pull/68

(#68 is a refactored version from #67 which can be ignored, I closed #67)

spiffyjr commented 11 years ago

Checking now and closing this issue.