/**
  * @var AfterSaveEvent $event
  */
 public function afterSave($event)
 {
     /** @var ActiveRecord $owner */
     $owner = $event->sender;
     foreach ($this->attributes as $attribute) {
         $category = str_replace(['{Class}', '{attribute}'], [strtolower($owner->formName()), $attribute], $this->category);
         $condition = ['category' => $category, 'message' => static::getOldAttribute($event, $attribute)];
         $data = ['category' => $category, 'message' => $owner->getAttribute($attribute)];
         switch ($event->name) {
             case ActiveRecord::EVENT_AFTER_INSERT:
             case ActiveRecord::EVENT_AFTER_UPDATE:
                 $model = SourceMessage::findOne($condition) ?: new SourceMessage($data);
                 $model->save(false);
                 break;
             case ActiveRecord::EVENT_AFTER_DELETE:
                 SourceMessage::deleteAll($condition);
                 break;
         }
     }
 }
 /**
  * Deletes all source and translation messages.
  * @param $id
  * @throws \Exception
  */
 public function actionDelete($id)
 {
     SourceMessage::findOne($id)->delete();
 }