mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fixed class references in Events guide
This commit is contained in:
@ -202,7 +202,7 @@ Sometimes, you may want to respond to an event triggered by *every* instance of
|
||||
a specific instance. Instead of attaching an event handler to every instance, you may attach the handler
|
||||
on the *class level* by calling the static method [[yii\base\Event::on()]].
|
||||
|
||||
For example, an [Active Record](db-active-record.md) object will trigger an [[yii\base\ActiveRecord::EVENT_AFTER_INSERT]]
|
||||
For example, an [Active Record](db-active-record.md) object will trigger an [[yii\db\BaseActiveRecord::EVENT_AFTER_INSERT|EVENT_AFTER_INSERT]]
|
||||
event whenever it inserts a new record into the database. In order to track insertions done by *every*
|
||||
[Active Record](db-active-record.md) object, you may use the following code:
|
||||
|
||||
@ -216,8 +216,8 @@ Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_INSERT, function
|
||||
});
|
||||
```
|
||||
|
||||
The event handler will be invoked whenever an instance of [[yii\base\ActiveRecord|ActiveRecord]], or one of its child classes, triggers
|
||||
the [[yii\base\ActiveRecord::EVENT_AFTER_INSERT|EVENT_AFTER_INSERT]] event. In the handler, you can get the object
|
||||
The event handler will be invoked whenever an instance of [[yii\db\ActiveRecord|ActiveRecord]], or one of its child classes, triggers
|
||||
the [[yii\db\BaseActiveRecord::EVENT_AFTER_INSERT|EVENT_AFTER_INSERT]] event. In the handler, you can get the object
|
||||
that triggered the event through `$event->sender`.
|
||||
|
||||
When an object triggers an event, it will first call instance-level handlers, followed by the class-level handlers.
|
||||
|
Reference in New Issue
Block a user