Skip to content

Commit

Permalink
[*] PROJECT : Adding hook on dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienSerny committed May 17, 2012
1 parent 811eccd commit 27206c3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion classes/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public function dispatch()
if (!isset($controllers[$this->controller]))
$this->controller = $this->controller_not_found;
$controller_class = $controllers[$this->controller];
$paramsHookActionDispatcher = array('controller_type' => self::FC_FRONT, 'controller_class' => $controller_class, 'is_module' => 0);
break;

// Dispatch module controller for front office
Expand All @@ -283,6 +284,7 @@ public function dispatch()
$controller_class = $module_name.$this->controller.'ModuleFrontController';
}
}
$paramsHookActionDispatcher = array('controller_type' => self::FC_FRONT, 'controller_class' => $controller_class, 'is_module' => 1);
break;

// Dispatch back office controller + module back office controller
Expand All @@ -308,13 +310,15 @@ public function dispatch()
$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
{
$controllers = Dispatcher::getControllers(array(_PS_ADMIN_DIR_.'/tabs/', _PS_ADMIN_CONTROLLER_DIR_));
if (!isset($controllers[$this->controller]))
$this->controller = $this->controller_not_found;
$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'))
$retrocompatibility_admin_tab = _PS_ADMIN_DIR_.'/tabs/'.$controller_class.'.php';
Expand All @@ -337,7 +341,15 @@ public function dispatch()
// Instantiate controller
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)
{
Expand Down

0 comments on commit 27206c3

Please sign in to comment.