-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation's behavior needs clarification #4845
Comments
There's no such thing as default event handler. Where did you get this understanding from? |
@qiangxue , class CActiveRecordBehavior extends CModelBehavior
{
...
public function events()
{
return array_merge(parent::events(), array(
'onBeforeSave'=>'beforeSave',
'onAfterSave'=>'afterSave',
'onBeforeDelete'=>'beforeDelete',
'onAfterDelete'=>'afterDelete',
'onBeforeFind'=>'beforeFind',
'onAfterFind'=>'afterFind',
'onBeforeCount'=>'beforeCount',
));
}
.... So I thought it's a typical approach throughout the system - to provide default method handler names. However, from the user's point of view, who is migrating from v1 to v2, the issue remains. We are used to extend from |
The The only thing changed is that we dropped |
I think this should be in the documentation to prevent confusion. Mainly that was what the issue is about. |
Another argument to support this is that most of the behaviors written seem to be extending |
Added the doc as suggested. Thanks. |
In the documentation: https://github.com/yiisoft/yii2/blob/master/docs/guide/concept-behaviors.md#handling-component-events
This example
is questionable, since, if I get behavior logic right, beforeValidate($event) should be triggered, as it is default handler for the ActiveRecord::EVENT_BEFORE_VALIDATE.
If I am right, we should expand on "default" handlers in text and add some custom name for a handler method, as it is rather confusing.
If I am understanding the mechanism wrong, than the issue is invalid and issue should be closed. In this case, I ask somebody of the contributors to answer my design questions in the forum:
Thanks.
The text was updated successfully, but these errors were encountered: