/** * {@inheritdoc} */ public function execute(BlockContextInterface $blockContext, Response $response = null) { $criteria = array('mode' => $blockContext->getSetting('mode')); $parameters = array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'pager' => $this->manager->getPager($criteria, 1, $blockContext->getSetting('number')), 'admin_pool' => $this->adminPool); if ($blockContext->getSetting('mode') === 'admin') { return $this->renderPrivateResponse($blockContext->getTemplate(), $parameters, $response); } return $this->renderResponse($blockContext->getTemplate(), $parameters, $response); }
/** * Retrieves the comments of specified post. * * @ApiDoc( * requirements={ * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Post id"} * }, * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}}, * statusCodes={ * 200="Returned when successful", * 404="Returned when post is not found" * } * ) * * @QueryParam(name="page", requirements="\d+", default="1", description="Page for comments list pagination") * @QueryParam(name="count", requirements="\d+", default="10", description="Number of comments by page") * * @Route(requirements={"_format"="json|xml"}) * * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true) * * @param int $id A post identifier * @param ParamFetcherInterface $paramFetcher * * @return PagerInterface */ public function getPostCommentsAction($id, ParamFetcherInterface $paramFetcher) { $post = $this->getPost($id); $page = $paramFetcher->get('page'); $count = $paramFetcher->get('count'); $criteria = $this->filterCriteria($paramFetcher); $criteria['postId'] = $post->getId(); /** @var PagerInterface $pager */ $pager = $this->commentManager->getPager($criteria, $page, $count); return $pager; }