From 9f7663fccceeeb7d3b00f6ee32cc5da70d7190c0 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 28 Feb 2012 00:32:30 -0600 Subject: [PATCH] Updated to latest view-layer changes - 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 | 9 ++++++++ module/Application/view/error/404.phtml | 33 ++++++++++++++++++--------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/module/Application/config/module.config.php b/module/Application/config/module.config.php index 2ae21f0..dd2f0d7 100644 --- a/module/Application/config/module.config.php +++ b/module/Application/config/module.config.php @@ -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, ), ), diff --git a/module/Application/view/error/404.phtml b/module/Application/view/error/404.phtml index 1afb866..aa5771d 100644 --- a/module/Application/view/error/404.phtml +++ b/module/Application/view/error/404.phtml @@ -1,22 +1,33 @@

A 404 error occurred

message ?>

-display_exceptions) && $this->display_exceptions): ?> +reason) && $this->reason): ?> -exception) && $this->exception instanceof Exception): ?> +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; +} +?> -

Exception information:

-

-

Message:

-
exception->getMessage() ?>
-

Stack trace:

-
exception->getTraceAsString() ?>
-

+

No Exception available

- - \ No newline at end of file -- 1.7.10.4