/**
* 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);
}