/**
  * Build Post
  * @return Post
  */
 protected function buildPost()
 {
     $request = $this->request;
     $post = new Post();
     $post->setContent($request->get('content'));
     $post->setAuthor($request->get('author'));
     $post->setEmail($request->get('email'));
     return $post;
 }
 /**
  * @inheritDoc
  */
 public function createNewThread($boardId, $params)
 {
     $board = $this->repositories->boards()->find($boardId);
     if (!$board instanceof Board) {
         throw new \OutOfBoundsException(sprintf('Board with ID `%s` not found', $boardId));
     }
     $thread = new Thread();
     $thread->setBoard($board);
     $post = new Post();
     $post->setEmail($params['post']['email']);
     $post->setAuthor($params['post']['author']);
     $post->setContent($params['post']['content']);
     $post->setThread($thread);
     $thread->getPosts()->add($post);
     $em = $this->repositories->getEntityManager();
     $em->persist($post);
     $em->persist($thread);
     $em->flush();
     return $thread;
 }
 /**
  * @inheritDoc
  */
 public function format(Post $post)
 {
     return ['id' => $post->getId(), 'thread_id' => (string) $post->getThread()->getId(), 'author' => $post->getAuthor(), 'email' => $post->getEmail(), 'content' => $post->getContent(), 'created_on' => $post->getDateCreatedOn()->format(\DateTime::ISO8601), 'updated_on' => $post->getDateUpdatedOn()->format(\DateTime::ISO8601), 'attachments' => $post->getAttachments()];
 }