Commit 452fcc0f by Qiang Xue

Fixes #4845

parent a12e1630
......@@ -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
--------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment