public function testAbortingPersistence() { $comment = $this->getMock('FOS\\CommentBundle\\Model\\CommentInterface'); $event = new CommentPersistEvent($comment); $this->assertFalse($event->isPersistenceAborted()); $event->abortPersistence(); $this->assertTrue($event->isPersistenceAborted()); }
public function spamCheck(CommentPersistEvent $event) { $comment = $event->getComment(); if ($this->spamDetector->isSpam($comment)) { if (null !== $this->logger) { $this->logger->info('Comment is marked as spam from detector, aborting persistence.'); } $event->abortPersistence(); } }
public function onCommentPrePersist(CommentPersistEvent $event) { $comment = $event->getComment(); // var_dump($comment->getNotifyToAdmin()); // die; if (!$this->commentManager->isNewComment($comment)) { return; } if ($comment instanceof SignedCommentInterface) { $author = $comment->getAuthor(); } $this->send_report_reply($comment->getThread()->getIncident(), $comment->getBody(), !$comment->getNotifyToAdmin()); }