/** * 찬성 * * @param ItemEntity $item board item entity * @param MemberEntityInterface $author user instance * @return void */ public function add(ItemEntity $item, MemberEntityInterface $author) { if ($this->invoked($item->id, $author) === false) { $doc = $item->getDocument(); $this->init(); $this->counter->add($doc->id, $author); $this->updateCount($doc); } }
/** * increment vote count * * @param Board $board board model * @param UserInterface $user user * @param string $option 'assent' or 'dissent' * @return void */ public function incrementVoteCount(Board $board, UserInterface $user, $option, $point = 1) { $this->voteCounter->add($board->id, $user, $option, $point); $columnName = 'assentCount'; if ($option == 'dissent') { $columnName = 'dissentCount'; } $board->{$columnName} = $this->voteCounter->getPoint($board->id, $option); $board->save(); }
/** * 찬성 * * @param ItemEntity $item board item entity * @param MemberEntityInterface $author user instance * @param string $option 'assent' or 'dissent' * @return void */ public function add(ItemEntity $item, MemberEntityInterface $author, $option) { $doc = $item->getDocument(); $this->counter->init(self::COUNTER_NAME, $option); $this->counter->add($doc->id, $author); $count = $this->count($doc->id); if ($option == 'assent') { $doc->assentCount = $count['assent']; } elseif ($option == 'dissent') { $doc->dissentCount = $count['dissent']; } $this->document->rawPut($doc); }