[*] PROJECT : Adding hook on dispatcher

This commit is contained in:
fSerny committed 2012-05-17 11:50:28 +00:00
1 parent 3ea14ea72b
commit 30b584d0d0
1 file changed
+13 -1
+13 -1
View File
@@ -267,6 +267,7 @@ class DispatcherCore
if (!isset($controllers[$this->controller])) if (!isset($controllers[$this->controller]))
$this->controller = $this->controller_not_found; $this->controller = $this->controller_not_found;
$controller_class = $controllers[$this->controller]; $controller_class = $controllers[$this->controller];
$paramsHookActionDispatcher = array('controller_type' => self::FC_FRONT, 'controller_class' => $controller_class, 'is_module' => 0);
break; break;
// Dispatch module controller for front office // Dispatch module controller for front office
@@ -283,6 +284,7 @@ class DispatcherCore
$controller_class = $module_name.$this->controller.'ModuleFrontController'; $controller_class = $module_name.$this->controller.'ModuleFrontController';
} }
} }
$paramsHookActionDispatcher = array('controller_type' => self::FC_FRONT, 'controller_class' => $controller_class, 'is_module' => 1);
break; break;
// Dispatch back office controller + module back office controller // Dispatch back office controller + module back office controller
@@ -308,6 +310,7 @@ class DispatcherCore
$controller_class = $controllers[$this->controller].(strpos($controllers[$this->controller], 'Controller') ? '' : 'Controller'); $controller_class = $controllers[$this->controller].(strpos($controllers[$this->controller], 'Controller') ? '' : 'Controller');
} }
} }
$paramsHookActionDispatcher = array('controller_type' => self::FC_ADMIN, 'controller_class' => $controller_class, 'is_module' => 1);
} }
else else
{ {
@@ -315,6 +318,7 @@ class DispatcherCore
if (!isset($controllers[$this->controller])) if (!isset($controllers[$this->controller]))
$this->controller = $this->controller_not_found; $this->controller = $this->controller_not_found;
$controller_class = $controllers[$this->controller]; $controller_class = $controllers[$this->controller];
$paramsHookActionDispatcher = array('controller_type' => self::FC_ADMIN, 'controller_class' => $controller_class, 'is_module' => 0);
if (file_exists(_PS_ADMIN_DIR_.'/tabs/'.$controller_class.'.php')) if (file_exists(_PS_ADMIN_DIR_.'/tabs/'.$controller_class.'.php'))
$retrocompatibility_admin_tab = _PS_ADMIN_DIR_.'/tabs/'.$controller_class.'.php'; $retrocompatibility_admin_tab = _PS_ADMIN_DIR_.'/tabs/'.$controller_class.'.php';
@@ -337,7 +341,15 @@ class DispatcherCore
// Instantiate controller // Instantiate controller
try try
{ {
Controller::getController($controller_class)->run(); // Loading controller
$controller = Controller::getController($controller_class);
// Execute hook dispatcher
if (isset($paramsHookActionDispatcher))
Hook::exec('actionDispatcher', $paramsHookActionDispatcher);
// Running controller
$controller->run();
} }
catch (PrestaShopException $e) catch (PrestaShopException $e)
{ {