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(); } }