Пример #1
0
 /**
  * 删除一篇文章
  * 
  * @param int $id
  * 
  * @throws \Exception\Msg
  * 
  * @return int
  */
 public static function destory($id)
 {
     $data = self::show($id);
     if (empty($data)) {
         throw new \Exception\Msg(_('文章不存在'));
     }
     User::validateAuth($data['uid']);
     //发布至Github中
     try {
         $publish_result = Publish::articleDestroy($id);
     } catch (\Exception\Api $e) {
         if ($e->getCode() != 404) {
             throw $e;
         }
     }
     $result = parent::destory($id);
     if ($result) {
         //计数器-1
         Counter\Article::decr($data['category_id']);
         Counter\Article::decr(0);
     }
     return $result;
 }