コード例 #1
0
 /**
  * Retrieves the list of pages (paginated)
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for 'page' list pagination")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Number of pages by page")
  * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled pages filter")
  * @QueryParam(name="edited", requirements="0|1", nullable=true, strict=true, description="Edited/Up to date pages filter")
  * @QueryParam(name="internal", requirements="0|1", nullable=true, strict=true, description="Internal/Exposed pages filter")
  * @QueryParam(name="root", requirements="0|1", nullable=true, strict=true, description="Filter pages having no parent id")
  * @QueryParam(name="site", requirements="\d+", nullable=true, strict=true, description="Filter pages for a specific site's id")
  * @QueryParam(name="parent", requirements="\d+", nullable=true, strict=true, description="Get pages beeing child of given page id")
  * @QueryParam(name="orderBy", requirements="ASC|DESC", array=true, nullable=true, strict=true, description="Order by array (key is field, value is direction)")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return PagerInterface
  */
 public function getPagesAction(ParamFetcherInterface $paramFetcher)
 {
     $supportedFilters = array('enabled' => '', 'edited' => '', 'internal' => '', 'root' => '', 'site' => '', 'parent' => '');
     $page = $paramFetcher->get('page');
     $count = $paramFetcher->get('count');
     $orderBy = $paramFetcher->get('orderBy');
     $filters = array_intersect_key($paramFetcher->all(), $supportedFilters);
     foreach ($filters as $key => $value) {
         if (null === $value) {
             unset($filters[$key]);
         }
     }
     $pager = $this->pageManager->getPager($filters, $page, $count);
     return $pager;
 }
コード例 #2
0
 /**
  * Retrieves the list of pages (paginated).
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for 'page' list pagination")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Number of pages by page")
  * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled pages filter")
  * @QueryParam(name="edited", requirements="0|1", nullable=true, strict=true, description="Edited/Up to date pages filter")
  * @QueryParam(name="internal", requirements="0|1", nullable=true, strict=true, description="Internal/Exposed pages filter")
  * @QueryParam(name="root", requirements="0|1", nullable=true, strict=true, description="Filter pages having no parent id")
  * @QueryParam(name="site", requirements="\d+", nullable=true, strict=true, description="Filter pages for a specific site's id")
  * @QueryParam(name="parent", requirements="\d+", nullable=true, strict=true, description="Get pages beeing child of given page id")
  * @QueryParam(name="orderBy", requirements="ASC|DESC", array=true, nullable=true, strict=true, description="Order by array (key is field, value is direction)")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return PagerInterface
  */
 public function getPagesAction(ParamFetcherInterface $paramFetcher)
 {
     $supportedCriteria = array('enabled' => '', 'edited' => '', 'internal' => '', 'root' => '', 'site' => '', 'parent' => '');
     $page = $paramFetcher->get('page');
     $limit = $paramFetcher->get('count');
     $sort = $paramFetcher->get('orderBy');
     $criteria = array_intersect_key($paramFetcher->all(), $supportedCriteria);
     foreach ($criteria as $key => $value) {
         if (null === $value) {
             unset($criteria[$key]);
         }
     }
     if (!$sort) {
         $sort = array();
     } elseif (!is_array($sort)) {
         $sort = array($sort => 'asc');
     }
     $pager = $this->pageManager->getPager($criteria, $page, $limit, $sort);
     return $pager;
 }