當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Post::afterSave方法代碼示例

本文整理匯總了PHP中common\models\Post::afterSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP Post::afterSave方法的具體用法?PHP Post::afterSave怎麽用?PHP Post::afterSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common\models\Post的用法示例。


在下文中一共展示了Post::afterSave方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if (isset(Yii::$app->params['setting']) && Yii::$app->params['setting']['xunsearch']) {
         if ($insert) {
             $search = new Search();
             $search->topic_id = $this->id;
             $search->status = self::STATUS_ACTIVE;
         } else {
             $search = Search::findOne($this->id);
             if (!$search) {
                 // 如果立即修改 會因為在 xunsearch 找不到而不能 save
                 return false;
             }
             $search->status = $this->status;
         }
         $search->title = $this->title;
         $search->content = $this->content;
         $search->updated_at = $this->updated_at;
         $search->save();
     }
 }
開發者ID:tqsq2005,項目名稱:getyii,代碼行數:22,代碼來源:Topic.php

示例2: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($insert) {
         $search = new Search();
         $search->topic_id = $this->id;
         $search->status = self::STATUS_ACTIVE;
     } else {
         //            Yii::$app->cache->set('topic' . $this->id, $this, 0);
         $search = Search::findOne($this->id);
         //            $search = false;
         if (!$search) {
             // 如果立即修改 會因為在 xunsearch 找不到而不能 save
             return false;
         }
         $search->status = $this->status;
     }
     $search->title = $this->title;
     $search->content = $this->content;
     $search->updated_at = $this->updated_at;
     $search->save();
 }
開發者ID:richardcj,項目名稱:getyii,代碼行數:22,代碼來源:Topic.php

示例3: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     (new UserMeta())->saveNewMeta($this->type, $this->id, 'follow');
     (new NotificationService())->newPostNotify(\Yii::$app->user->identity, $this, $this->atUsers);
 }
開發者ID:iiyii,項目名稱:getyii,代碼行數:6,代碼來源:Tweet.php

示例4: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if (isset(Yii::$app->params['setting']) && Yii::$app->params['setting']['xunsearch']) {
         if ($insert) {
             $search = new Search();
             $search->topic_id = $this->id;
             $search->status = self::STATUS_ACTIVE;
         } else {
             $search = Search::findOne($this->id);
             if (!$search) {
                 // 如果立即修改 會因為在 xunsearch 找不到而不能 save
                 return false;
             }
             $search->status = $this->status;
         }
         $search->title = $this->title;
         $search->content = $this->content;
         $search->updated_at = $this->updated_at;
         $search->save();
     }
     (new NotificationService())->newPostNotify(\Yii::$app->user->identity, $this, $this->atUsers);
     if ($insert) {
         // 保存 meta data
         (new UserMeta())->saveNewMeta('topic', $this->id, 'follow');
         // 更新個人總統計
         UserInfo::updateAllCounters(['post_count' => 1], ['user_id' => $this->user_id]);
     }
 }
開發者ID:iiyii,項目名稱:getyii,代碼行數:29,代碼來源:Topic.php


注:本文中的common\models\Post::afterSave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。