Merge remote-tracking branch 'ocramius/better-exception-information'
authorEvan Coury <me@evancoury.com>
Fri, 2 Mar 2012 20:05:20 +0000 (13:05 -0700)
committerEvan Coury <me@evancoury.com>
Fri, 2 Mar 2012 20:05:20 +0000 (13:05 -0700)
module/Application/Module.php
module/Application/config/module.config.php
module/Application/view/error/404.phtml
module/Application/view/layout/layout.phtml
vendor/ZendFramework

index 75282d9..4d0c318 100644 (file)
@@ -8,9 +8,6 @@ use Zend\Module\Manager,
 
 class Module implements AutoloaderProvider
 {
-    protected $view;
-    protected $viewListener;
-
     public function init(Manager $moduleManager)
     {
         $events = StaticEventManager::getInstance();
index 2ae21f0..fd748ee 100644 (file)
@@ -29,9 +29,17 @@ return array(
             // Setup the View layer
             'Zend\View\Resolver\AggregateResolver' => array(
                 'injections' => array(
+                    'Zend\View\Resolver\TemplateMapResolver',
                     'Zend\View\Resolver\TemplatePathStack',
                 ),
             ),
+            'Zend\View\Resolver\TemplateMapResolver' => array(
+                'parameters' => array(
+                    'map'  => array(
+                        'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
+                    ),
+                ),
+            ),
             'Zend\View\Resolver\TemplatePathStack' => array(
                 'parameters' => array(
                     'paths'  => array(
@@ -46,18 +54,20 @@ return array(
             ),
             'Zend\Mvc\View\DefaultRenderingStrategy' => array(
                 'parameters' => array(
-                    'baseTemplate' => 'layout/layout',
+                    'layoutTemplate' => 'layout/layout',
                 ),
             ),
             'Zend\Mvc\View\ExceptionStrategy' => array(
                 'parameters' => array(
                     'displayExceptions' => true,
-                    'template'          => 'error/index',
+                    'exceptionTemplate' => 'error/index',
                 ),
             ),
             'Zend\Mvc\View\RouteNotFoundStrategy' => array(
                 'parameters' => array(
-                    'notFoundTemplate' => 'error/404',
+                    'displayNotFoundReason' => true,
+                    'displayExceptions'     => true,
+                    'notFoundTemplate'      => 'error/404',
                 ),
             ),
 
index 1afb866..468953f 100644 (file)
@@ -1,22 +1,60 @@
 <h1>A 404 error occurred</h1>
 <h2><?php echo $this->message ?></h2>
 
-<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>
+<?php if (isset($this->reason) && $this->reason): ?>
 
-<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>
+<?php
+$reasonMessage= '';
+switch ($this->reason) {
+    case 'error-controller-cannot-dispatch':
+        $reasonMessage = 'The requested controller was unable to dispatch the request.';
+        break;
+    case 'error-controller-not-found':
+        $reasonMessage = 'The requested controller could not be mapped to an existing controller class.';
+        break;
+    case 'error-controller-invalid':
+        $reasonMessage = 'The requested controller was not dispatchable.';
+        break;
+    case 'error-router-no-match':
+        $reasonMessage = 'The requested URL could not be matched by routing.';
+        break;
+    default:
+        $reasonMessage = 'We cannot determine at this time why a 404 was generated.';
+        break;
+}
+?>
 
-<h3>Exception information:</h3>
-<p>
-    <h4>Message:</h4>
-    <pre><?php echo $this->exception->getMessage() ?></pre>
-    <h4>Stack trace:</h4>
-    <pre><?php echo $this->exception->getTraceAsString() ?></pre>
-</p>
+<p><?php echo $reasonMessage ?></p>
 
-<?php else: ?>
+<?php endif ?>
+
+<?php if (isset($this->controller) && $this->controller): ?>
 
-<h3>No Exception available</h3>
+<dl>
+    <dt>Controller:</dt>
+    <dd><?php $this->escape($this->controller) ?>
+<?php
+if (isset($this->controller_class) 
+    && $this->controller_class
+    && $this->controller_class != $this->controller
+) {
+    echo " (resolves to " . $this->escape($this->controller_class) . ")";
+}
+?>
+</dd>
 
 <?php endif ?>
 
-<?php endif ?>
\ No newline at end of file
+<?php if (isset($this->exception) && $this->exception): ?>
+
+<h2>Exception:</h2>
+
+<p><b><?php echo $this->escape($this->exception->getMessage()) ?></b></p>
+
+<h3>Stack trace</h3>
+
+<pre>
+<?php echo $this->exception->getTraceAsString() ?>
+</pre>
+
+<?php endif ?>
index 4d3c4e6..622c108 100644 (file)
@@ -25,7 +25,7 @@ echo $this->doctype();
     <meta charset="utf-8">
     <?php echo $this->headTitle('ZF2 Skeleton Application') ?>
 
-    <?php echo $this->headMeta()->appendName('viewport', 'width=device-width, initial-scale=1.0') ?>
+    <?php echo $this->headMeta() ?>
 
     <!-- Le styles -->
     <?php echo $this->headLink() ?>
@@ -58,12 +58,12 @@ echo $this->doctype();
 
     <div class="container">
 
-      <?php echo $this->raw('content'); ?>
+      <?php echo $this->content; ?>
 
       <hr>
 
       <footer>
-        <p>&copy; 2006 - <?php echo date('Y') ?> by Zend Technologies Ltd. All rights reserved.</p>
+        <p>&copy; 2006 - 2012 by Zend Technologies Ltd. All rights reserved.</p>
       </footer>
 
     </div> <!-- /container -->
index 2141369..f62d7b4 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 2141369ca32da2cbabbe5ddea546c806dd4ca7f5
+Subproject commit f62d7b47e2ab86e58ba3d6e219135fd01b6d4c09