Example #1
0
 /**
  * Removes a Post
  * @param    Courtyard\Forum\Entity\PostInterface
  */
 public function delete($post)
 {
     if ($post->getNumber() == 1) {
         throw new \BadMethodCallException('Cannot delete the first post of a topic');
     }
     $postEvent = new PostEvent($post);
     $postEvent->addEntityToRemove($post);
     $this->dispatcher->dispatch($this->dispatcher->newTransaction()->addFirstPass(ForumEvents::POST_DELETE_PRE, $postEvent)->addSecondPass(ForumEvents::POST_DELETE_POST, clone $postEvent));
 }