本文整理汇总了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();
}
}
示例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();
}
示例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);
}
示例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]);
}
}