diff --git a/Controller/ContentController.php b/Controller/ContentController.php index 77bf223..974c5df 100644 --- a/Controller/ContentController.php +++ b/Controller/ContentController.php @@ -30,7 +30,9 @@ class ContentController extends Controller */ protected function snippetActionData($slug) { - return $this->get('ongr_content.content_service')->getDataForSnippet($slug); + return [ + 'document' => $this->get('ongr_content.content_service')->getDocumentBySlug($slug) + ]; } /** diff --git a/Resources/views/Content/plain_cms_snippet.html.twig b/Resources/views/Content/plain_cms_snippet.html.twig index a224218..4b444e1 100644 --- a/Resources/views/Content/plain_cms_snippet.html.twig +++ b/Resources/views/Content/plain_cms_snippet.html.twig @@ -1 +1 @@ -{{ include(template_from_string(content)) }} +{{ include(template_from_string(document.content)) }} diff --git a/Service/ContentService.php b/Service/ContentService.php index f561c07..519203d 100644 --- a/Service/ContentService.php +++ b/Service/ContentService.php @@ -50,36 +50,14 @@ public function getDocumentBySlug($slug) $results = $this->repository->execute($search); - if (isset($results)) { - return $results->current(); - } - - return null; - } - - /** - * Returns data for content snippet render action. - * - * @param string $slug - * - * @return array - */ - public function getDataForSnippet($slug) - { - $document = $this->getDocumentBySlug($slug); - - if (!$document) { + if (!isset($results)) { $this->logger && $this->logger->warning( sprintf("Can not render snippet for '%s' because content was not found.", $slug) ); - return ['content' => '', 'title' => null, 'document' => null]; + return null; } - return [ - 'content' => $document->content, - 'title' => $document->title, - 'document' => $document, - ]; + return $results->current(); } }