/**
  * @inheritDoc
  */
 public function getPosts(PostQuery $postQuery)
 {
     $repo = $this->repositories->posts();
     $limit = $postQuery->getSeek()->getLimit();
     $offset = $postQuery->getSeek()->getOffset();
     $order = ['id' => 'desc'];
     $criteria = ['thread' => $postQuery->getThreadId()];
     return $repo->findBy($criteria, $order, $limit, $offset);
 }
 /**
  * @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 getAllBoards()
 {
     return $this->repositories->boards()->findAll();
 }