From: Andrey Kutejko Date: Sun, 29 Dec 2013 15:53:24 +0000 (+0200) Subject: admin model listeners X-Git-Tag: 0.6~214 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=1f82de459327870dd58b2e50362390f8ab4d2f1a;p=ipf.git admin model listeners --- diff --git a/ipf/admin/model.php b/ipf/admin/model.php index 7b76a94..a0c069b 100644 --- a/ipf/admin/model.php +++ b/ipf/admin/model.php @@ -343,6 +343,37 @@ class DateHierarchyListFilter extends BaseListFilter { } } +class IPF_Admin_ModelListener +{ + public function beforeEdit($o) + { + $this->beforeChange($o); + } + + public function beforeAdd($o) + { + $this->beforeChange($o); + } + + public function beforeChange($o) + { + } + + public function afterEdit($o) + { + $this->afterChange($o); + } + + public function afterAdd($o) + { + $this->afterChange($o); + } + + public function afterChange($o) + { + } +} + class IPF_Admin_Model { static $models = array(); @@ -387,6 +418,7 @@ class IPF_Admin_Model var $inlineInstances = array(); var $perPage = 50; public $hidden = false; + public $modelListeners = array(); public function __construct($modelName) { @@ -608,24 +640,33 @@ class IPF_Admin_Model protected function _beforeEdit($o) { + foreach ($this->modelListeners as $l) + $l->beforeEdit($o); $this->_beforeChange($o); } protected function _beforeAdd($o) { + foreach ($this->modelListeners as $l) + $l->beforeAdd($o); $this->_beforeChange($o); } - protected function _beforeChange($o){ + protected function _beforeChange($o) + { } protected function _afterEdit($o) { + foreach ($this->modelListeners as $l) + $l->afterEdit($o); $this->_afterChange($o); } protected function _afterAdd($o) { + foreach ($this->modelListeners as $l) + $l->afterAdd($o); $this->_afterChange($o); }