[-] MO: exec hook on hook registration #PSCFV-8977

This commit is contained in:
Rémi Gaillard
2013-07-01 16:12:33 +02:00
parent 0e0d8c58d0
commit 09359d011f
4 changed files with 21 additions and 6 deletions
+2
View File
@@ -668,6 +668,7 @@ abstract class ModuleCore
if ($alias = Hook::getRetroHookName($hook_name))
$hook_name = $alias;
Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
// Get hook id
$id_hook = Hook::getIdByName($hook_name);
@@ -714,6 +715,7 @@ abstract class ModuleCore
));
}
Hook::exec('actionModuleRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name));
return $return;
}
+2 -2
View File
@@ -15,5 +15,5 @@ CHANGE `module_name` `module_name` VARCHAR(64) NULL DEFAULT NULL;
/* PHP:add_module_to_hook(blocksupplier, actionObjectSupplierAddAfter); */;
/* PHP:add_module_to_hook(blocksupplier, actionObjectSupplierUpdateAfter); */;
/* PHP:fix_download_product_feature_active(); */;
/* PHP:add_module_to_hook(blockmyaccount, actionModuleRegisterHookAfter); */;
/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleRegisterHookAfter); */;
+8 -1
View File
@@ -48,7 +48,8 @@ class BlockMyAccount extends Module
if (!$this->addMyAccountBlockHook()
|| !parent::install()
|| !$this->registerHook('displayLeftColumn')
|| !$this->registerHook('displayHeader'))
|| !$this->registerHook('displayHeader')
|| !$this->registerHook('actionModuleRegisterHookAfter'))
return false;
return true;
}
@@ -58,6 +59,12 @@ class BlockMyAccount extends Module
return (parent::uninstall() && $this->removeMyAccountBlockHook());
}
public function hookActionModuleRegisterHookAfter($params)
{
if ($params['hook_name'] == 'displayMyAccountBlock')
$this->_clearCache('blockmyaccount.tpl');
}
public function hookDisplayLeftColumn($params)
{
if (!$this->context->customer->isLogged())
@@ -33,7 +33,7 @@ class Blockmyaccountfooter extends Module
{
$this->name = 'blockmyaccountfooter';
$this->tab = 'front_office_features';
$this->version = '1.2';
$this->version = '1.3';
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -45,7 +45,7 @@ class Blockmyaccountfooter extends Module
public function install()
{
if (!$this->addMyAccountBlockHook() || !parent::install() || !$this->registerHook('footer') || !$this->registerHook('header'))
if (!$this->addMyAccountBlockHook() || !parent::install() || !$this->registerHook('footer') || !$this->registerHook('header') || !$this->registerHook('actionModuleRegisterHookAfter'))
return false;
return true;
}
@@ -55,6 +55,12 @@ class Blockmyaccountfooter extends Module
return parent::uninstall() && $this->removeMyAccountBlockHook();
}
public function hookActionModuleRegisterHookAfter($params)
{
if ($params['hook_name'] == 'displayMyAccountBlock')
$this->_clearCache('blockmyaccountfooter.tpl');
}
public function hookLeftColumn($params)
{
global $smarty;
@@ -97,7 +103,7 @@ class Blockmyaccountfooter extends Module
$smarty->assign(array(
'voucherAllowed' => CartRule::isFeatureActive(),
'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN')),
'HOOK_BLOCK_MY_ACCOUNT' => Hook::exec('displayMyAccountBlock')
'HOOK_BLOCK_MY_ACCOUNT' => Hook::exec('displayMyAccountBlockfooter')
));
return $this->display(__FILE__, 'blockmyaccountfooter.tpl', $this->getCacheId());
}