From ef4bab29af1e4dd5aac3f87f1c3d8391808d514d Mon Sep 17 00:00:00 2001 From: Evan Coury Date: Sun, 18 Dec 2011 07:56:38 -0700 Subject: [PATCH] Update view listener to pass vars to layout - Enable display exceptions by defualt - Cannot pass a variable called 'content' to layout --- module/Application/config/module.config.php | 2 +- module/Application/src/Application/View/Listener.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/module/Application/config/module.config.php b/module/Application/config/module.config.php index 9c6302a..ef54756 100644 --- a/module/Application/config/module.config.php +++ b/module/Application/config/module.config.php @@ -1,7 +1,7 @@ 'layouts/layout.phtml', - 'display_exceptions' => false, + 'display_exceptions' => true, 'di' => array( 'instance' => array( 'alias' => array( diff --git a/module/Application/src/Application/View/Listener.php b/module/Application/src/Application/View/Listener.php index ac4c4b7..fc99fba 100644 --- a/module/Application/src/Application/View/Listener.php +++ b/module/Application/src/Application/View/Listener.php @@ -127,7 +127,7 @@ class Listener implements ListenerAggregate $content = $this->view->render($script, $vars); - $e->setResult($content); + $e->setParam('content', $content); return $content; } @@ -142,13 +142,15 @@ class Listener implements ListenerAggregate return $response; } - $footer = $e->getParam('footer', false); - $vars = array('footer' => $footer); + $vars = $e->getResult(); + if (is_scalar($vars)) { + $vars = array('content' => $vars); + } elseif (is_object($vars) && !$vars instanceof ArrayAccess) { + $vars = (array) $vars; + } if (false !== ($contentParam = $e->getParam('content', false))) { $vars['content'] = $contentParam; - } else { - $vars['content'] = $e->getResult(); } $layout = $this->view->render($this->layout, $vars); -- 1.7.10.4