本文整理匯總了PHP中app\models\Tag::afterTopicEdit方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tag::afterTopicEdit方法的具體用法?PHP Tag::afterTopicEdit怎麽用?PHP Tag::afterTopicEdit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Tag
的用法示例。
在下文中一共展示了Tag::afterTopicEdit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionEdit
public function actionEdit($id)
{
$request = Yii::$app->getRequest();
$me = Yii::$app->getUser()->getIdentity();
$model = $this->findTopicModel($id, ['content', 'node']);
if (!$me->canEdit($model)) {
throw new ForbiddenHttpException('您沒有權限修改或已超過可修改時間。');
}
if ($me->isAdmin()) {
$model->scenario = Topic::SCENARIO_ADMIN_EDIT;
} else {
$model->scenario = Topic::SCENARIO_AUTHOR_EDIT;
}
if (!($content = $model->content)) {
$content = new TopicContent(['topic_id' => $model->id]);
}
$oldTags = $model->tags;
if ($model->load($request->post()) && $model->validate() && $content->load($request->post()) && $content->validate()) {
// $model->tags = Tag::editTags($model->tags, $oldTags);
$model->tags = Tag::getTags($model->tags);
$model->save(false) && $content->save(false);
Tag::afterTopicEdit($model->id, $model->tags, $oldTags);
(new History(['user_id' => $me->id, 'action' => History::ACTION_EDIT_TOPIC, 'action_time' => $model->updated_at, 'target' => $model->id]))->save(false);
return $this->redirect(Topic::getRedirectUrl($id, 0, $request->get('ip', 1), $request->get('np', 1)));
}
return $this->render('edit', ['model' => $model, 'content' => $content]);
}