Skip to content

Commit

Permalink
Fixes yiisoft#4845
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangxue committed Aug 28, 2014
1 parent a12e163 commit 452fcc0
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion docs/guide/intro-upgrade-from-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------------

Expand Down

0 comments on commit 452fcc0

Please sign in to comment.