findDeletedTopic() public static méthode

获取已经删除过的话题
public static findDeletedTopic ( $id ) : array | Topic | null | ActiveRecord
$id
Résultat array | Topic | null | ActiveRecord
 /**
  * 撤消删除
  * @param $id
  * @return \yii\web\Response
  * @throws NotFoundHttpException
  */
 public function actionRevoke($id)
 {
     $model = Topic::findDeletedTopic($id);
     if (!$model->isCurrent()) {
         throw new NotFoundHttpException();
     }
     $model->updateCounters(['status' => 1]);
     $this->flash("「{$model->title}」文章撤销删除成功。", 'success');
     return $this->redirect(['/topic/default/view', 'id' => $model->id]);
 }
Exemple #2
0
 /**
  * 撤消删除
  * @param $id
  * @return \yii\web\Response
  * @throws NotFoundHttpException
  */
 public function actionRevoke($id)
 {
     $model = Topic::findDeletedTopic($id);
     if (!($model && (User::getThrones() || $model->isCurrent()))) {
         throw new NotFoundHttpException();
     }
     TopicService::revoke($model);
     $this->flash("「{$model->title}」文章撤销删除成功。", 'success');
     return $this->redirect(['/topic/default/view', 'id' => $model->id]);
 }