/** * Delivers related videos in JSON format. */ public function getRelatedVideos() { $searchConfig = F::build('WikiaSearchConfig'); if ($this->getVal('id', false)) { $searchConfig->setPageId($this->getVal('id')); } $searchConfig->setStart(0)->setSize(20); $mltResult = $this->wikiaSearch->getRelatedVideos($searchConfig); $responseData = array(); foreach ($mltResult as $document) { $responseData[$document['url']] = $document->getFields(); } $this->response->setData($responseData); $this->response->setFormat('json'); }