src/Db/Orm/BaseActiveRecord.php
public function afterSave($insert, $changedAttributes)
    {
        $eventName = $insert ? self::EVENT_AFTER_INSERT : self::EVENT_AFTER_UPDATE;
        $this->emit($eventName, [&$this, $changedAttributes]);
    }
public function afterSave($insert, $changedAttributes)
    {
        $eventName = $insert ? self::EVENT_AFTER_INSERT : self::EVENT_AFTER_UPDATE;
        $this->emit($eventName, [&$this, $changedAttributes]);
    }
This method is called at the end of inserting or updating a record.
The default implementation will trigger an [[EVENT_AFTER_INSERT]] event when `$insert` is `true`,
or an [[EVENT_AFTER_UPDATE]] event if `$insert` is `false`. The event class used is [[AfterSaveEvent]].
When overriding this method, make sure you call the parent implementation so that
the event is triggered.
@param bool $insert whether this method called while inserting a record.
If `false`, it means the method is called while updating a record.
@param array $changedAttributes The old values of attributes that had changed and were saved.
You can use this parameter to take action based on the changes made for example send an email
when the password had changed or implement audit trail that tracks all the changes.
`$changedAttributes` gives you the old attribute values while the active record (`$this`) has
already the new, updated values.

Note that no automatic type conversion performed by default. You may use
[[\yii\behaviors\AttributeTypecastBehavior]] to facilitate attribute typecasting.
See http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#attributes-typecasting.