public function contentAction(OrmManager $orm, Cms $cms, ContentService $contentService, ImageUrlGenerator $imageUrlGenerator, $model, $id, $locale) { $model = $orm->getModel($model); $entry = $model->getById($id); if (!$entry) { $this->response->setStatusCode(Response::STATUS_CODE_NOT_FOUND); return; } $site = $cms->getCurrentSite($this->request->getBaseUrl(), $locale); $content = $contentService->getContentForEntry($model, $entry, $site->getId(), $locale); if ($content->image) { $transformation = $this->request->getQueryParameter('transformation', 'crop'); $options = array('width' => $this->request->getQueryParameter('width', 100), 'height' => $this->request->getQueryParameter('height', 100)); $content->image = $imageUrlGenerator->generateUrl($content->image, $transformation, $options); } unset($content->data); $this->setJsonView($content); }
/** * Gets the result from the query * @param \ride\web\cms\orm\ContentProperties $properties * @param \ride\library\orm\query\ModelQuery $query * @return array Array with Content objects */ protected function getResult(ContentProperties $contentProperties, ContentService $contentService, ModelQuery $query) { $entry = $query->queryFirst(); if (!$entry) { return $entry; } $node = $this->properties->getNode(); $titleFormat = $contentProperties->getContentTitleFormat(); $teaserFormat = $contentProperties->getContentTeaserFormat(); $imageFormat = $contentProperties->getContentImageFormat(); $dateFormat = $contentProperties->getContentDateFormat(); return $contentService->getContentForEntry($this->model, $entry, $node->getRootNodeId(), $this->locale, null, $titleFormat, $teaserFormat, $imageFormat, $dateFormat); }