Updated to latest view-layer changes
authorMatthew Weier O'Phinney <matthew@zend.com>
Tue, 28 Feb 2012 06:32:30 +0000 (00:32 -0600)
committerMatthew Weier O'Phinney <matthew@zend.com>
Tue, 28 Feb 2012 06:32:30 +0000 (00:32 -0600)
- Added configuration for TemplateMapResolver
- Added configuration for displayNotFoundReason
- Updated error/404 template to display the 404 reason, if enabled.
- Please merge only after https://github.com/zendframework/zf2/pull/851

module/Application/config/module.config.php
module/Application/view/error/404.phtml

index 2ae21f0..dd2f0d7 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(
@@ -58,6 +66,7 @@ return array(
             'Zend\Mvc\View\RouteNotFoundStrategy' => array(
                 'parameters' => array(
                     'notFoundTemplate' => 'error/404',
+                    'displayNotFoundReason' => true,
                 ),
             ),
 
index 1afb866..aa5771d 100644 (file)
@@ -1,22 +1,33 @@
 <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: ?>
 
 <h3>No Exception available</h3>
 
 <?php endif ?>
-
-<?php endif ?>
\ No newline at end of file