Пример #1
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");
         }
     }
 }
Пример #2
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;
     }
 }
Пример #3
0
 public function _assignToDefault($categoryId)
 {
     $defaultCategory = FaqCategory::getDefault($this->getAccountId());
     $condition = ['isDeleted' => false, 'faqCategoryId' => $categoryId];
     $results = Faq::find()->where($condition)->all();
     foreach ($results as $result) {
         $result['faqCategoryId'] = $defaultCategory->_id . '';
         $result->save();
     }
 }
Пример #4
0
 public function actionGetCategoryList()
 {
     $accountId = $this->getAccountId();
     $categoryList = FaqCategory::getAll($accountId);
     return $categoryList;
 }