/** * Assigns the currently logged in user to a Comment. * * @throws InvalidArgumentException when the Comment is not a SignedCommentInterface * @param CommentInterface $comment * @return void */ public function blame(CommentInterface $comment) { if (!$comment instanceof SignedCommentInterface) { throw new InvalidArgumentException('The comment must implement SignedCommentInterface'); } if (null === $this->securityContext->getToken()) { throw new RuntimeException('You must configure a firewall for this route'); } if ($this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) { $comment->setAuthor($this->securityContext->getToken()->getUser()); } }