/** * Assigns the Security token's user to the vote. * * @param VoteEvent $vote * @return void */ public function blame(VoteEvent $event) { $vote = $event->getVote(); if (null === $this->securityContext) { if ($this->logger) { $this->logger->debug("Vote Blamer did not receive the security.context service."); } return; } if (!$vote instanceof SignedVoteInterface) { if ($this->logger) { $this->logger->debug("Vote does not implement SignedVoteInterface, skipping"); } return; } if (null === $this->securityContext->getToken()) { if ($this->logger) { $this->logger->debug("There is no firewall configured. We cant get a user."); } return; } if ($this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) { $vote->setVoter($this->securityContext->getToken()->getUser()); } }
/** * Assigns the Security token's user to the vote. * * @param VoteEvent $vote */ public function blame(VoteEvent $event) { $vote = $event->getVote(); if (!$vote instanceof SignedVoteInterface) { if ($this->logger) { $this->logger->debug("Vote does not implement SignedVoteInterface, skipping"); } return; } if (null === $this->tokenStorage->getToken()) { if ($this->logger) { $this->logger->debug("There is no firewall configured. We cant get a user."); } return; } if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { $vote->setVoter($this->tokenStorage->getToken()->getUser()); } }
public function onVotePersist(VoteEvent $event) { $vote = $event->getVote(); $comment = $vote->getComment(); $comment->incrementScore($vote->getValue()); }