[*] PROJECT - Dynamic hooks in ObjectModel retrieve object in param - Dynamic hooks have been added to AdminController

This commit is contained in:
fSerny
2011-12-05 17:20:40 +00:00
parent 55518a08b3
commit 460f085fd3
2 changed files with 28 additions and 9 deletions
+22 -3
View File
@@ -466,10 +466,29 @@ class AdminControllerCore extends Controller
$this->processFilter();
if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action))))
return $this->{'process'.Tools::toCamelCase($this->action)}($token);
else if (method_exists($this, $this->action))
return call_user_func(array($this, $this->action), $this->boxes);
{
/* Hook Before Action */
Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
$return = $this->{'process'.Tools::toCamelCase($this->action)}($token);
/* Hook After Action */
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
return $return;
}
else if (method_exists($this, $this->action))
{
/* Hook Before Action */
Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
$return = call_user_func(array($this, $this->action), $this->boxes);
/* Hook After Action */
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
return $return;
}
}
}
+6 -6
View File
@@ -229,7 +229,7 @@ abstract class ObjectModelCore
throw new PrestashopException('not table or identifier : '.$this->table);
/* Hook */
Hook::exec('actionObject'.get_class($this).'AddBefore');
Hook::exec('actionObject'.get_class($this).'AddBefore', array('object' => $this));
/* Automatically fill dates */
if ($autodate AND key_exists('date_add', $this))
@@ -285,7 +285,7 @@ abstract class ObjectModelCore
}
/* Hook */
Hook::exec('actionObject'.get_class($this).'AddAfter');
Hook::exec('actionObject'.get_class($this).'AddAfter', array('object' => $this));
return $result;
}
@@ -301,7 +301,7 @@ abstract class ObjectModelCore
throw new PrestashopException('wrong identifier or table:'.$this->identifier.', table: '.$this->table);
/* Hook */
Hook::exec('actionObject'.get_class($this).'UpdateBefore');
Hook::exec('actionObject'.get_class($this).'UpdateBefore', array('object' => $this));
$this->clearCache();
/* Automatically fill dates */
@@ -360,7 +360,7 @@ abstract class ObjectModelCore
}
/* Hook */
Hook::exec('actionObject'.get_class($this).'UpdateAfter');
Hook::exec('actionObject'.get_class($this).'UpdateAfter', array('object' => $this));
return $result;
}
@@ -376,7 +376,7 @@ abstract class ObjectModelCore
throw new PrestashopException('wrong identifier or table:'.$this->identifier.', table: '.$this->table);
/* Hook */
Hook::exec('actionObject'.get_class($this).'DeleteBefore');
Hook::exec('actionObject'.get_class($this).'DeleteBefore', array('object' => $this));
$this->clearCache();
@@ -398,7 +398,7 @@ abstract class ObjectModelCore
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.$this->table.'_group_shop` WHERE `'.$this->identifier.'`='.(int)$this->id);
/* Hook */
Hook::exec('actionObject'.get_class($this).'DeleteAfter');
Hook::exec('actionObject'.get_class($this).'DeleteAfter', array('object' => $this));
return $result;
}