[-] BO : catch prestashop exception and display smart error messages #PSCFV-9147
This commit is contained in:
@@ -513,37 +513,42 @@ class AdminControllerCore extends Controller
|
|||||||
*/
|
*/
|
||||||
public function postProcess()
|
public function postProcess()
|
||||||
{
|
{
|
||||||
if ($this->ajax)
|
try {
|
||||||
{
|
if ($this->ajax)
|
||||||
// from ajax-tab.php
|
|
||||||
$action = Tools::getValue('action');
|
|
||||||
// no need to use displayConf() here
|
|
||||||
if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action)))
|
|
||||||
return $this->{'ajaxProcess'.Tools::toCamelCase($action)}();
|
|
||||||
elseif (method_exists($this, 'ajaxProcess'))
|
|
||||||
return $this->ajaxProcess();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Process list filtering
|
|
||||||
if ($this->filter)
|
|
||||||
$this->processFilter();
|
|
||||||
|
|
||||||
// If the method named after the action exists, call "before" hooks, then call action method, then call "after" hooks
|
|
||||||
if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action))))
|
|
||||||
{
|
{
|
||||||
// Hook before action
|
// from ajax-tab.php
|
||||||
Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
|
$action = Tools::getValue('action');
|
||||||
Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
|
// no need to use displayConf() here
|
||||||
// Call process
|
if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action)))
|
||||||
$return = $this->{'process'.Tools::toCamelCase($this->action)}();
|
return $this->{'ajaxProcess'.Tools::toCamelCase($action)}();
|
||||||
// Hook After Action
|
elseif (method_exists($this, 'ajaxProcess'))
|
||||||
Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
|
return $this->ajaxProcess();
|
||||||
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
// Process list filtering
|
||||||
|
if ($this->filter)
|
||||||
|
$this->processFilter();
|
||||||
|
|
||||||
|
// If the method named after the action exists, call "before" hooks, then call action method, then call "after" hooks
|
||||||
|
if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action))))
|
||||||
|
{
|
||||||
|
// Hook before action
|
||||||
|
Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
|
||||||
|
Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
|
||||||
|
// Call process
|
||||||
|
$return = $this->{'process'.Tools::toCamelCase($this->action)}();
|
||||||
|
// Hook After Action
|
||||||
|
Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
|
||||||
|
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (PrestaShopException $e) {
|
||||||
|
$this->errors[] = $e->getMessage();
|
||||||
|
};
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1161,6 +1166,7 @@ class AdminControllerCore extends Controller
|
|||||||
header('Location: '.$this->redirect_after);
|
header('Location: '.$this->redirect_after);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function display()
|
public function display()
|
||||||
{
|
{
|
||||||
$this->context->smarty->assign(array(
|
$this->context->smarty->assign(array(
|
||||||
|
|||||||
Reference in New Issue
Block a user