コード例 #1
0
ファイル: Delete.php プロジェクト: codigoirreverente/LampCMS
 /**
  * Update count of questions or answers
  * in the category
  *
  * @return \Lampcms\Controllers\Delete
  */
 protected function updateCategory()
 {
     $Updator = new \Lampcms\Category\Updator($this->Registry->Mongo);
     if ('QUESTIONS' === $this->collection) {
         $Updator->removeQuestion($this->Resource);
     } else {
         $Updator->removeAnswer($this->Resource);
     }
     return $this;
 }
コード例 #2
0
 protected function updateCategory()
 {
     $Updator = new \Lampcms\Category\Updator($this->Registry->Mongo);
     $Updator->addAnswer($this->Answer);
     return $this;
 }
コード例 #3
0
ファイル: Editor.php プロジェクト: codigoirreverente/LampCMS
 /**
  * If ID of category of question changes
  * must update the counter of questions in the new category (+1)
  * and decrease count in old category (-1)
  *
  * If question has any answers must update counter of answers in old category (-$numAnswers)
  * and increase counter in new category (+$numAnswers)
  *
  * @param $oldCategoryId
  * @param $newCategoryId
  *
  * @return $this
  * @throws \InvalidArgumentException if $oldId or $newId is not an integer
  * @internal param int $oldId
  * @internal param int $newId
  *
  */
 protected function updateCategoryCounter($oldCategoryId, $newCategoryId)
 {
     if (!is_int($oldCategoryId)) {
         throw new \InvalidArgumentException('$oldCategoryId is not an integer');
     }
     if (!is_int($newCategoryId)) {
         throw new \InvalidArgumentException('$newCategoryId is not an integer');
     }
     $CategoryUpdator = new \Lampcms\Category\Updator($this->Registry->Mongo);
     $CategoryUpdator->removeQuestionById($this->Resource[QuestionSchema::PRIMARY], $oldCategoryId);
     $CategoryUpdator->increaseQuestionCount($newCategoryId);
     $answersCount = $this->Resource[QuestionSchema::NUM_ANSWERS];
     d('Count of answers: ' . $answersCount);
     if ($answersCount > 0) {
         $CategoryUpdator->decreaseAnswerCount($oldCategoryId, $answersCount);
         $CategoryUpdator->increaseAnswerCount($newCategoryId, $answersCount);
     }
     return $this;
 }