public function formatApi(Workflow $listWorkflow, array $workflows, array $found, PagerPage $page, IContextSource $ctx)
 {
     $res = $this->buildResult($workflows, $found, $ctx) + $this->buildEmptyResult($listWorkflow);
     $pagingOption = $page->getPagingLinksOptions();
     $res['links']['pagination'] = $this->buildPaginationLinks($listWorkflow, $pagingOption);
     $title = $listWorkflow->getArticleTitle();
     $saveSortBy = true;
     $res['links']['board-sort']['updated'] = $this->urlGenerator->boardLink($title, 'updated', $saveSortBy)->getLinkURL();
     $res['links']['board-sort']['newest'] = $this->urlGenerator->boardLink($title, 'newest', $saveSortBy)->getLinkURL();
     // Link to designated new-topic page, for no-JS users
     $res['links']['newtopic'] = $this->urlGenerator->newTopicAction($title, $listWorkflow->getId())->getLinkURL();
     return $res;
 }
 /**
  * Formats the response
  *
  * @param Workflow $listWorkflow Workflow corresponding to board/list of topics
  * @param array $topicRootRevisionsByWorkflowId Associative array mapping topic ID (in alphadecimal form)
  *  to PostRevision for the topic root.
  * @param array $workflowsByWorkflowId Associative array mapping topic ID (in alphadecimal form) to
  *  workflow
  * @param PagerPage $page page from query, to support pagination
  *
  * @return array Array formatted for response
  */
 public function formatApi(Workflow $listWorkflow, $topicRootRevisionsByWorkflowId, $workflowsByWorkflowId, PagerPage $page)
 {
     $result = $this->buildEmptyResult($listWorkflow);
     foreach ($topicRootRevisionsByWorkflowId as $topicId => $postRevision) {
         $result['roots'][] = $topicId;
         $revisionId = $postRevision->getRevisionId()->getAlphadecimal();
         $result['posts'][$topicId] = array($revisionId);
         $contentFormat = 'plaintext';
         $workflow = $workflowsByWorkflowId[$topicId];
         $result['revisions'][$revisionId] = array('content' => array('content' => $this->templating->getContent($postRevision, $contentFormat), 'format' => $contentFormat), 'last_updated' => $workflow->getLastModifiedObj()->getTimestamp() * 1000);
     }
     $pagingOption = $page->getPagingLinksOptions();
     $result['links']['pagination'] = $this->buildPaginationLinks($listWorkflow, $pagingOption);
     return $result;
 }