/**
  *
  * @access protected
  * @param \Map2u\ForumBundle\Entity\Post $post
  */
 protected function onSuccess(Post $post)
 {
     $post->setCreatedDate(new \DateTime());
     $post->setCreatedBy($this->user);
     $post->setDeleted(false);
     $topic = $post->getTopic();
     $topic->setCachedViewCount(0);
     $topic->setCachedReplyCount(0);
     $topic->setClosed(false);
     $topic->setDeleted(false);
     $topic->setSticky(false);
     $this->dispatcher->dispatch(ForumEvents::USER_TOPIC_CREATE_SUCCESS, new UserTopicEvent($this->request, $topic));
     $this->postModel->savePost($post);
     $topic->setFirstPost($post);
     $topic->setLastPost($post);
     $this->topicModel->saveTopic($topic);
     $this->dispatcher->dispatch(ForumEvents::USER_TOPIC_CREATE_COMPLETE, new UserTopicEvent($this->request, $topic, $this->didAuthorSubscribe()));
 }
 /**
  *
  * @access protected
  * @param \Map2u\ForumBundle\Entity\Post $post
  */
 protected function onSuccess(Post $post)
 {
     $post->setCreatedDate(new \DateTime());
     $post->setCreatedBy($this->user);
     $post->setTopic($this->topic);
     $post->setDeleted(false);
     $this->dispatcher->dispatch(ForumEvents::USER_TOPIC_REPLY_SUCCESS, new UserTopicEvent($this->request, $post->getTopic()));
     $this->postModel->savePost($post);
     $this->dispatcher->dispatch(ForumEvents::USER_TOPIC_REPLY_COMPLETE, new UserTopicEvent($this->request, $this->topic, $this->didAuthorSubscribe()));
 }
Example #3
0
 /**
  *
  * @access public
  * @param  \Map2u\ForumBundle\Entity\Post                  $post
  * @param  \Symfony\Component\Security\Core\User\UserInterface $user
  * @return \Map2u\ForumBundle\Manager\ManagerInterface
  */
 public function softDelete(Post $post, UserInterface $user)
 {
     // Don't overwite previous users accountability.
     if (!$post->getDeletedBy() && !$post->getDeletedDate()) {
         $post->setDeleted(true);
         $post->setDeletedBy($user);
         $post->setDeletedDate(new \DateTime());
         // update the record
         $this->persist($post)->flush();
     }
     return $this;
 }