public function saveVote(VoteInterface $vote) { if (null === $vote->getComment()) { throw new \InvalidArgumentException('Vote passed into saveVote must have a comment'); } $event = new VoteEvent($vote); $this->dispatcher->dispatch(Events::VOTE_PRE_PERSIST, $event); $this->doSaveVote($vote); $event = new VoteEvent($vote); $this->dispatcher->dispatch(Events::VOTE_POST_PERSIST, $event); }
/** * Persists a vote. * * @param \FOS\CommentBundle\Model\VoteInterface $vote */ protected function doSaveVote(VoteInterface $vote) { $this->em->persist($vote->getComment()); $this->em->persist($vote); $this->em->flush(); }
/** * {@inheritDoc} */ public function saveVote(VoteInterface $vote) { if (!$this->voteAcl->canCreate()) { throw new AccessDeniedException(); } if (!$this->commentAcl->canView($vote->getComment())) { throw new AccessDeniedException(); } $this->realManager->saveVote($vote); $this->voteAcl->setDefaultAcl($vote); }