From 489623972f8b7ee4f1b029c73095894b43e4dded Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 14 Apr 2016 19:05:57 +0000 Subject: [PATCH] route : allow to define a viewErrorClass and viewErrorMethod to catch the exceptions raised by the code. Simplfy the index.php : $route->viewClass = '\views\ipsets'; $route->viewErrorMethod = 'error'; $ipsetsObj = new \controllers\ipsets (); $form = new \form (); $values = $form->values (); $errors = $ipsetsObj->verify ($values); $form->redirectIfErrors ($values, $errors, "/ipsets/add"); $ipsetsObj->createSet ($values["setname"], $values["typename"]); $route->redirect ("/ipsets", ""); git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2696 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- route.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/route.php b/route.php index d2d7e4e..34273da 100644 --- a/route.php +++ b/route.php @@ -47,6 +47,10 @@ class route public $viewClass = FALSE; /** Method apply to class object to display the $result */ public $viewMethod = FALSE; + /** Classname containing the error layer */ + public $viewErrorClass = null; + /** Method apply to class object to display the error */ + public $viewErrorMethod = null; /** Filename in views containing the HTML layout. Without .html at the end */ public $layout = FALSE; /** Array to search/replace */ @@ -559,8 +563,14 @@ class route $renderer->result = $message; $renderer->output = $this->output; $renderer->title = $http->codetext ($getCode); - $renderer->viewClass = $this->viewClass; - $renderer->viewMethod = $this->viewMethod; + if ($this->viewErrorClass !== null) + $renderer->viewClass = $this->viewErrorClass; + else + $renderer->viewClass = $this->viewClass; + if ($this->viewErrorMethod !== null) + $renderer->viewMethod = $this->viewErrorMethod; + else + $renderer->viewMethod = $this->viewMethod; $renderer->layout = $this->layout; $renderer->replacement = array_merge ($this->replacement, array ("{exceptionCode}"=>$getCode,