Update view listener to pass vars to layout
authorEvan Coury <me@evancoury.com>
Sun, 18 Dec 2011 14:56:38 +0000 (07:56 -0700)
committerEvan Coury <me@evancoury.com>
Sun, 18 Dec 2011 14:56:38 +0000 (07:56 -0700)
- Enable display exceptions by defualt
- Cannot pass a variable called 'content' to layout

module/Application/config/module.config.php
module/Application/src/Application/View/Listener.php

index 9c6302a..ef54756 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 return array(
     'layout'                => 'layouts/layout.phtml',
-    'display_exceptions'    => false,
+    'display_exceptions'    => true,
     'di'                    => array(
         'instance' => array(
             'alias' => array(
index ac4c4b7..fc99fba 100644 (file)
@@ -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);