/**
  * @param Thread $thread
  * @param User $user
  * @return Thread
  */
 public function create(Thread $thread, User $user)
 {
     $thread->setUser($user)->setLastPostedAt(null);
     $this->threadRepository->add($thread);
     $this->entityManager->flush();
     return $thread;
 }
 /**
  * @param Thread $thread
  * @param Post $post
  * @return Post
  */
 public function register(Thread $thread, Post $post)
 {
     $thread->addPost($post)->setLastPostedAt($this->currentDate());
     $post->setThread($thread);
     $this->threadRepository->add($thread);
     $this->entityManager->flush();
     return $post;
 }