예제 #1
0
 public function actionAddFaqCategory()
 {
     $params = $this->getParams();
     $accountId = $this->getAccountId();
     $faqCategory = new FaqCategory();
     $faqCategory->accountId = $accountId;
     $faqCategory->name = $params['category'];
     if ($faqCategory->save()) {
         return $faqCategory;
     } else {
         throw new ServerErrorHttpException("Save FAQ category failed!");
     }
 }
예제 #2
0
 /**
  * Create default FAQ category
  * @param  \MongoId $accountId
  * @throws ServerErrorHttpException when save the record for default FAQ category failed.
  */
 private function _createDefaultCategory(\MongoId $accountId)
 {
     $defaultCategory = FaqCategory::getDefault($accountId);
     if (empty($defaultCategory)) {
         $category = new FaqCategory();
         $category->name = self::DEFAULT_CATEGORY;
         $category->isDefault = true;
         $category->accountId = $accountId;
         if (!$category->save()) {
             throw new ServerErrorHttpException("create default FAQ category failed");
         }
     }
 }
예제 #3
0
 /**
  * add default category for account.
  */
 private function _createDefaultCategory($accountId)
 {
     $defaultCategory = FaqCategory::getDefault($accountId);
     if (empty($defaultCategory)) {
         $category = new FaqCategory();
         $category->name = "默认分类";
         $category->isDefault = true;
         $category->accountId = $accountId;
         if (!$category->save()) {
             echo $category->getErrors() . PHP_EOL;
             exit;
         }
     } else {
         echo $accountId . 'data is exists' . PHP_EOL;
     }
 }