Skip to content

Commit

Permalink
removed getDataForSnippet method
Browse files Browse the repository at this point in the history
  • Loading branch information
Martynas Sudintas committed Nov 3, 2014
1 parent f251b94 commit d97e0e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
4 changes: 3 additions & 1 deletion Controller/ContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/Content/plain_cms_snippet.html.twig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ include(template_from_string(content)) }}
{{ include(template_from_string(document.content)) }}
28 changes: 3 additions & 25 deletions Service/ContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit d97e0e1

Please sign in to comment.