Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Dev Fixed some bugs reported by @seracom.
  • Loading branch information
SamMousa committed Sep 4, 2013
1 parent 5a22c58 commit 9d0a803
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions application/models/behaviors/PluginEventBehavior.php
Expand Up @@ -4,28 +4,38 @@ class PluginEventBehavior extends CModelBehavior
public function events()
{
return array_merge(parent::events(), array(
'onBeforeSave' => 'beforeSave',
'onAfterDelete' => 'afterDelete',
'onAfterSave' => 'afterSave',
'onBeforeDelete' => 'beforeDelete',
'onBeforeSave' => 'beforeSave',


));
}

public function afterSave(CModelEvent $event)
public function afterDelete(CEvent $event)
{
$this->dispatchPluginModelEvent('after'.get_class($this->owner).'Delete');
$this->dispatchPluginModelEvent('afterModelDelete');
}
public function afterSave(CEvent $event)
{
$this->dispatchPluginModelEvent('after'.get_class($this->owner).'Save');
$this->dispatchPluginModelEvent('afterModelSave');
}
public function beforeDelete(CModelEvent $event)
{
$this->dispatchPluginModelEvent('before'.get_class($this->owner).'Delete');
$this->dispatchPluginModelEvent('beforeModelDelete');
}

public function beforeSave(CModelEvent $event)
{
$this->dispatchPluginModelEvent('before'.get_class($this->owner).'Save');
$this->dispatchPluginModelEvent('beforeModelSave');
}

public function beforeDelete(CModelEvent $event)
{
$this->dispatchPluginModelEvent('before'.get_class($this->owner).'Delete');
$this->dispatchPluginModelEvent('beforeModelDelete');
}


/**
* method for dispatching plugin events
Expand All @@ -35,7 +45,7 @@ public function beforeDelete(CModelEvent $event)
* @param array $criteria array containing attributes, conditions and params for the filter query
* @return PluginEvent the dispatched event
*/
private function dispatchPluginModelEvent($sEventName, $criteria = null)
public function dispatchPluginModelEvent($sEventName, $criteria = null)
{
$oPluginEvent = new PluginEvent($sEventName, $this);
$oPluginEvent->set('model', $this->owner);
Expand Down

0 comments on commit 9d0a803

Please sign in to comment.