/** * Gets the content objects for the provided entries * @param \ride\library\orm\model\Model $model * @param array $entries * @param string $siteId * @param string $locale * @param string $idContentMapper * @param string $titleFormat * @param string $teaserFormat * @param string $imageFormat * @param string $dateFormat * @return array Array with Content objects for the provided entries * @see \ride\library\cms\content\Content */ public function getContentForEntries(Model $model, array $result, $siteId, $locale, $idContentMapper = null, $titleFormat = null, $teaserFormat = null, $imageFormat = null, $dateFormat = null) { $modelName = $model->getName(); $modelTable = $model->getMeta()->getModelTable(); $entryFormatter = $this->orm->getEntryFormatter(); if (!$titleFormat) { $titleFormat = $modelTable->getFormat(EntryFormatter::FORMAT_TITLE, false); if ($titleFormat == null) { $titleFormat = $model->getName() . ' #{id}'; } } if (!$teaserFormat && $modelTable->hasFormat(EntryFormatter::FORMAT_TEASER)) { $teaserFormat = $modelTable->getFormat(EntryFormatter::FORMAT_TEASER); } if (!$imageFormat && $modelTable->hasFormat(EntryFormatter::FORMAT_IMAGE)) { $imageFormat = $modelTable->getFormat(EntryFormatter::FORMAT_IMAGE); } if (!$dateFormat && $modelTable->hasFormat(EntryFormatter::FORMAT_DATE)) { $dateFormat = $modelTable->getFormat(EntryFormatter::FORMAT_DATE); } try { $mapper = $this->getContentMapper($modelName, $idContentMapper); } catch (Exception $e) { $mapper = new OrmContentMapper($this->nodeModel, $model, $entryFormatter); } foreach ($result as $index => $entry) { $title = $entryFormatter->formatEntry($entry, $titleFormat); $url = $mapper->getUrl($siteId, $locale, $entry); $teaser = null; if ($teaserFormat) { $teaser = $entryFormatter->formatEntry($entry, $teaserFormat); } $image = null; if ($imageFormat) { $image = $entryFormatter->formatEntry($entry, $imageFormat); } $date = null; if ($dateFormat) { $date = $entryFormatter->formatEntry($entry, $dateFormat); } $content = new Content($modelName, $title, $url, $teaser, $image, $date, $entry); $result[$index] = $content; } return $result; }