/** * Returns list of boards * @return Ok */ public function getAll() { $jsonResponse = []; /** @var Board $board */ foreach ($this->boardRepository->getAllBoards() as $board) { $jsonResponse[] = $this->boardToJSON($board); } return new Ok($jsonResponse); }
/** * Returns threads by board * @param $boardId * @param SeekableInterface $seek * @return Ok */ public function getByBoardId($boardId, SeekableInterface $seek) { $board = $this->boardRepository->getBoardById($boardId); $threadsQuery = new ThreadListQuery($board, $seek); $threadsQuery->withAllPosts(); $threadsQueryList = $this->threadRepository->getThreads($threadsQuery); $jsonResponse = ['items' => [], 'total' => $threadsQueryList->getTotal()]; foreach ($threadsQueryList->getItems() as $thread) { $jsonResponse['items'][] = $this->convertThreadToJSON($thread); } return new Ok($jsonResponse); }