Newscoop\Image\RenditionService::getRenditions PHP Метод

getRenditions() публичный Метод

Get renditions
public getRenditions ( ) : array
Результат array
    public function getRenditions()
    {
        if ($this->renditions === null) {
            $this->renditions = array();
            foreach ($this->orm->getRepository('Newscoop\\Image\\Rendition')->findBy(array(), array('offset' => 'asc', 'name' => 'asc')) as $rendition) {
                $this->renditions[$rendition->getName()] = $rendition;
            }
            if (empty($this->renditions)) {
                $this->registerRenditions();
            }
        }
        return $this->renditions;
    }

Usage Example

Пример #1
0
 /**
  * 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);
 }