/** * * @access public * @param \CCDNForum\ForumBundle\Entity\Post $post * @param \Symfony\Component\Security\Core\User\UserInterface $user * @return \CCDNForum\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; }
protected function createPost($topic, $body, $author) { $post = new Post(); $post->setTopic($topic); $post->setCreatedBy($author); $post->setCreatedDate(new \DateTime()); $post->setDeleted(false); $post->setBody($body); return $post; }
/** * * @access protected * @param \CCDNForum\ForumBundle\Entity\Post $post */ protected function onSuccess(Post $post) { $post->setCreatedDate(new \DateTime()); if ($this->anon) { $post->setAnonName($post->GetAnonName()); } else { $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())); }
/** * * @access protected * @param \CCDNForum\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())); }