/** * Get document for comment * * @param Newscoop\Entity\Comment $comment * @return array */ public function getDocument(DocumentInterface $comment) { $articleNumber = $comment->getThread(); $language = $comment->getLanguage(); $article = $this->em->getRepository('Newscoop\\Entity\\Article')->find(array('number' => $articleNumber, 'language' => $language->getId())); return array('id' => $this->getDocumentId($comment), 'number' => $comment->getId(), 'type' => 'comment', 'subject' => $comment->getSubject(), 'message' => $comment->getMessage(), 'published' => gmdate(self::DATE_FORMAT, $comment->getTimeCreated()->getTimestamp()), 'link' => sprintf('%s#comment_%d', $this->articleLinkService->getLink($article), $comment->getId())); }
/** * Get document representation for article * * @param Newscoop\Entity\Article $article * @return array */ public function getDocument(DocumentInterface $article) { $image = null; $renditions = $this->renditionService->getRenditions(); if (is_array($renditions) && count($renditions) > 0) { $image = $this->renditionService->getArticleRenditionImage($article->getNumber(), key($renditions)); } $webcode = $this->webcoder->getArticleWebcode($article); if (strpos($webcode, 0, 1) != '+') { $webcode = '+' . $webcode; } $doc = array('id' => $this->getDocumentId($article), 'number' => $article->getNumber(), 'type' => $article->getType(), 'webcode' => $webcode, 'title' => $article->getTitle(), 'updated' => gmdate(self::DATE_FORMAT, $article->getDate()->getTimestamp()), 'published' => gmdate(self::DATE_FORMAT, $article->getPublishDate()->getTimestamp()), 'image' => $image ? $image['src'] : null, 'link' => $this->linkService->getLink($article), 'language' => $article->getLanguageCode(), 'language_id' => $article->getLanguageId(), 'publication_number' => $article->getPublication() ? $article->getPublication()->getId() : null, 'issue_number' => $article->getIssue() ? $article->getIssue()->getNumber() : null, 'section_number' => $article->getSection() ? $article->getSection()->getNumber() : null, 'section_id' => $article->getSection() ? $article->getSection()->getNumber() : null, 'section' => $this->linkService->getSectionShortName($article), 'section_name' => $article->getSection() ? $article->getSection()->getName() : null, 'authors' => array_map(function ($author) { return $author->getFullName(); }, is_array($article->getArticleAuthors()) ? $article->getArticleAuthors() : array()), 'keywords' => explode(',', $article->getKeywords()), 'topics' => array_values($article->getTopicNames()), 'switches' => $this->getArticleSwitches($article)); $this->addDataFields($doc, $article); return array_filter($doc); }
/** * Get document for comment * * @param Newscoop\Entity\Comment $comment * @return array */ public function getDocument(DocumentInterface $comment) { return array('id' => $this->getDocumentId($comment), 'number' => $comment->getId(), 'type' => 'comment', 'subject' => $comment->getSubject(), 'message' => $comment->getMessage(), 'published' => gmdate(self::DATE_FORMAT, $comment->getTimeCreated()->getTimestamp()), 'link' => sprintf('%s#comment_%d', $this->articleLinkService->getLink($comment->getArticle()), $comment->getId())); }