示例#1
0
 public function afterSave($insert, $changedAttributes)
 {
     if ($insert === true) {
         if ($this->type === self::TYPE_NODE) {
             $action = 'followNode';
             Node::updateCounterInfo($action, $this->target_id);
         } else {
             if ($this->type === self::TYPE_TOPIC) {
                 $action = 'followTopic';
                 Topic::updateCounterInfo($action, $this->target_id);
                 Notice::afterFollow($this);
             } else {
                 if ($this->type === self::TYPE_USER) {
                     $action = 'followUser';
                     UserInfo::updateCounterInfo('followed', $this->target_id);
                     Notice::afterFollow($this);
                 }
             }
         }
         UserInfo::updateCounterInfo($action, Yii::$app->getUser()->getId());
     }
     return parent::afterSave($insert, $changedAttributes);
 }