Example #1
0
 /**
  * After Save, delete LikeCount (Cache) for target object
  */
 public function afterSave($insert, $changedAttributes)
 {
     Yii::$app->cache->delete('likes_' . $this->object_model . "_" . $this->object_id);
     $activity = new \humhub\modules\like\activities\Liked();
     $activity->source = $this;
     $activity->create();
     $notification = new \humhub\modules\like\notifications\NewLike();
     $notification->source = $this;
     $notification->originator = $this->user;
     $notification->sendBulk($this->content->getPolymorphicRelation()->getFollowers(null, true, true));
     return parent::afterSave($insert, $changedAttributes);
 }
Example #2
0
 /**
  * After Save, delete LikeCount (Cache) for target object
  */
 public function afterSave($insert, $changedAttributes)
 {
     Yii::$app->cache->delete('likes_' . $this->object_model . "_" . $this->object_id);
     $activity = new \humhub\modules\like\activities\Liked();
     $activity->source = $this;
     $activity->create();
     if ($this->getSource()->createdBy !== null) {
         $notification = new \humhub\modules\like\notifications\NewLike();
         $notification->source = $this;
         $notification->originator = $this->user;
         $notification->send($this->getSource()->createdBy);
     }
     return parent::afterSave($insert, $changedAttributes);
 }