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:
2016-04-14 19:05:57 +00:00
parent d35b61e290
commit 489623972f

View File

@@ -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,