/**
  * {@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);
 }
예제 #2
0
 /**
  * Retrieves the list of posts (paginated) based on criteria.
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for posts list pagination")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Number of posts by page")
  * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled posts filter")
  * @QueryParam(name="dateQuery", requirements=">|<|=", default=">", description="Date filter orientation (>, < or =)")
  * @QueryParam(name="dateValue", requirements="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-2][0-9]:[0-5][0-9]:[0-5][0-9]([+-][0-9]{2}(:)?[0-9]{2})?", nullable=true, strict=true, description="Date filter value")
  * @QueryParam(name="tag", requirements="\S+", nullable=true, strict=true, description="Tag name filter")
  * @QueryParam(name="author", requirements="\S+", nullable=true, strict=true, description="Author filter")
  * @QueryParam(name="mode", requirements="public|admin", default="public", description="'public' mode filters posts having enabled tags and author")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @Route(requirements={"_format"="json|xml"})
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return PagerInterface
  */
 public function getPostsAction(ParamFetcherInterface $paramFetcher)
 {
     $page = $paramFetcher->get('page');
     $count = $paramFetcher->get('count');
     $pager = $this->postManager->getPager($this->filterCriteria($paramFetcher), $page, $count);
     return $pager;
 }