Last active
February 28, 2016 09:51
-
-
Save janit/2a7e882be4d00967b139 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Displays the list of blog_post. | |
* | |
* @param \eZ\Publish\Core\MVC\Symfony\View\ContentView $view | |
* @param \Symfony\Component\HttpFoundation\Request $request | |
* | |
* @return \Symfony\Component\HttpFoundation\Response | |
*/ | |
public function listBlogPostsAction(ContentView $view, Request $request) | |
{ | |
$location = $view->getLocation(); | |
$languages = $this->configResolver->getParameter('languages'); | |
$query = new Query(); | |
$query->query = $this->childrenCriteria->generateChildCriterion($location, $languages); | |
$query->sortClauses = [ | |
new SortClause\Field('blog_post', 'publication_date', Query::SORT_DESC, $languages[0]), | |
]; | |
$pager = new Pagerfanta( | |
new ContentSearchAdapter($query, $this->searchService) | |
); | |
$pager->setMaxPerPage($this->blogPostLimit); | |
$pager->setCurrentPage($request->get('page', 1)); | |
$view->addParameters([ | |
'location' => $location, | |
'content' => $this->contentService->loadContentByContentInfo($view->getLocation()->getContentInfo()), | |
'blogPosts' => $pager, | |
]); | |
return $view; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment