/** * @inheritDoc */ public function format(Thread $thread) { $postFormatter = new PostFormatter(); $jsonResponse = ['thread' => ['id' => $thread->getId()], 'posts' => []]; foreach ($thread->getPosts() as $post) { $jsonResponse['posts'][] = $postFormatter->format($post); } return $jsonResponse; }
/** * Reply to thread * @param ThreadReplyQuery $replyQuery * @return array|mixed * @throws \Exception */ public function reply(ThreadReplyQuery $replyQuery) { $formatter = new PostFormatter(); $this->replyService->reply($replyQuery); return new Ok($formatter->format($replyQuery->getPost())); }