Skip to content

Commit

Permalink
Protected approach solution
Browse files Browse the repository at this point in the history
  • Loading branch information
creocoder committed Sep 20, 2012
1 parent 6674ced commit 4457ce3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion framework/base/CBehavior.php
Expand Up @@ -48,7 +48,7 @@ public function attach($owner)
$class=new ReflectionClass($this);
foreach($this->events() as $event=>$handler)
{
if(!$class->getMethod($handler)->getDeclaringClass()->hasProperty('_events_provider'))
if(!$class->getMethod($handler)->isProtected())
$owner->attachEventHandler($event,array($this,$handler));
}
}
Expand Down
7 changes: 3 additions & 4 deletions framework/base/CModelBehavior.php
Expand Up @@ -19,7 +19,6 @@
*/
class CModelBehavior extends CBehavior
{
private $_events_provider;
/**
* Declares events and the corresponding event handler methods.
* The default implementation returns 'onAfterConstruct', 'onBeforeValidate' and 'onAfterValidate' events and handlers.
Expand All @@ -41,7 +40,7 @@ public function events()
* Overrides this method if you want to handle the corresponding event of the {@link CBehavior::owner owner}.
* @param CEvent $event event parameter
*/
public function afterConstruct($event)
protected function afterConstruct($event)
{
}

Expand All @@ -51,7 +50,7 @@ public function afterConstruct($event)
* You may set {@link CModelEvent::isValid} to be false to quit the validation process.
* @param CModelEvent $event event parameter
*/
public function beforeValidate($event)
protected function beforeValidate($event)
{
}

Expand All @@ -60,7 +59,7 @@ public function beforeValidate($event)
* Overrides this method if you want to handle the corresponding event of the {@link owner}.
* @param CEvent $event event parameter
*/
public function afterValidate($event)
protected function afterValidate($event)
{
}
}
13 changes: 6 additions & 7 deletions framework/db/ar/CActiveRecordBehavior.php
Expand Up @@ -20,7 +20,6 @@
*/
class CActiveRecordBehavior extends CModelBehavior
{
private $_events_provider;
/**
* Declares events and the corresponding event handler methods.
* If you override this method, make sure you merge the parent result to the return value.
Expand All @@ -45,7 +44,7 @@ public function events()
* You may set {@link CModelEvent::isValid} to be false to quit the saving process.
* @param CModelEvent $event event parameter
*/
public function beforeSave($event)
protected function beforeSave($event)
{
}

Expand All @@ -54,7 +53,7 @@ public function beforeSave($event)
* Overrides this method if you want to handle the corresponding event of the {@link CBehavior::owner owner}.
* @param CModelEvent $event event parameter
*/
public function afterSave($event)
protected function afterSave($event)
{
}

Expand All @@ -64,7 +63,7 @@ public function afterSave($event)
* You may set {@link CModelEvent::isValid} to be false to quit the deletion process.
* @param CEvent $event event parameter
*/
public function beforeDelete($event)
protected function beforeDelete($event)
{
}

Expand All @@ -73,7 +72,7 @@ public function beforeDelete($event)
* Overrides this method if you want to handle the corresponding event of the {@link CBehavior::owner owner}.
* @param CEvent $event event parameter
*/
public function afterDelete($event)
protected function afterDelete($event)
{
}

Expand All @@ -82,7 +81,7 @@ public function afterDelete($event)
* Overrides this method if you want to handle the corresponding event of the {@link CBehavior::owner owner}.
* @param CEvent $event event parameter
*/
public function beforeFind($event)
protected function beforeFind($event)
{
}

Expand All @@ -91,7 +90,7 @@ public function beforeFind($event)
* Overrides this method if you want to handle the corresponding event of the {@link CBehavior::owner owner}.
* @param CEvent $event event parameter
*/
public function afterFind($event)
protected function afterFind($event)
{
}
}

0 comments on commit 4457ce3

Please sign in to comment.