Version 1 by Matthew Weier O'Phinney
on Jan 11, 2012 17:14.

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (2)

View Page History
{note:title=Prototype Available}
Updated 2012-01-14.

A prototype is available on GitHub: https://github.com/weierophinney/zf2/commits/feature/view-layer

To enable it, do something like the following from within a listener on the bootstrap event:
{code:php}
$app = $e->getParam('application');
$config = $e->getParam('config');
$locator = $app->getLocator();

// Get and attach view listener
$listener = $locator->get('Zend\Mvc\View\DefaultRenderingStrategy');
$app->events()->attachAggregate($listener);
{code}

A few items that have arisen from prototyping:
* We likely need a "render" or "view" event in the Application that triggers following the "dispatch" event.
* The callback on the "route" and "dispatch" events that looks for a returned response should likely also look for View\Model objects, and halt execution.
* Several folks have commented that a "convenience" listener should be introduced to allow returning arrays from controller actions. In such cases, this listener would auto-determine the view script based on controller and optionally action, and marshal a generic ViewModel instance with the returned array and the discovered view script name.
* We likely need some convenience around specifying default renderer options for ViewModel instances. As an example, if you plan on using layouts, you shouldn't need to inject the "enable_layout" option every time; additionally, there should be an easy way to specify the default layout. (The latter is done in the DefaultRenderingStrategy currently.)
{note}

Zend Framework 1.X conflated the View with the Renderer -- in other words, one was not done without the other.