This commit is contained in:
Qiang Xue
2014-08-28 10:32:34 -04:00
parent a12e1630df
commit 452fcc0fcf

View File

@ -459,13 +459,45 @@ public function init()
}
```
There where some problems with overriding the constructor of an ActiveRecord class in 1.1. These are not present in
There were some problems with overriding the constructor of an ActiveRecord class in 1.1. These are not present in
version 2.0 anymore. Note that when adding parameters to the constructor you might have to override [[yii\db\ActiveRecord::instantiate()]].
There are many other changes and enhancements to Active Record. Please refer to
the [Active Record](db-active-record.md) section for more details.
Active Record Behaviors
-----------------------
In 2.0, we have dropped the base behavior class `CActiveRecordBehavior`. If you want to create an Active Record Behavior,
you will have to extend directly from `yii\base\Behavior`. If the behavior class needs to respond to some events
of the owner, you have to override the `events()` method like the following,
```php
namespace app\components;
use yii\db\ActiveRecord;
use yii\base\Behavior;
class MyBehavior extends Behavior
{
// ...
public function events()
{
return [
ActiveRecord::EVENT_BEFORE_VALIDATE => 'beforeValidate',
];
}
public function beforeValidate($event)
{
// ...
}
}
```
User and IdentityInterface
--------------------------