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
This commit is contained in:
14
route.php
14
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,
|
||||
|
||||
Reference in New Issue
Block a user