/** * Public pagination method * * @\Mmoreram\ControllerExtraBundle\Annotation\Paginator( * attributes = "paginatorAttributes", * class = { * "factory" = "Mmoreram\ControllerExtraBundle\Tests\FakeBundle\Factory\FakeFactory", * "method" = "createNonStatic", * "static" = false * }, * limit = "#limit#", * page = "#page#", * wheres = { * { "x", "id" , "LIKE", "#id#", true } * }, * ) * * @\Mmoreram\ControllerExtraBundle\Annotation\JsonResponse() */ public function paginatorRequestAction(Paginator $paginator, PaginatorAttributes $paginatorAttributes) { return array('count' => $paginator->getIterator()->count(), 'totalPages' => $paginatorAttributes->getTotalPages(), 'totalElements' => $paginatorAttributes->getTotalElements(), 'currentPage' => $paginatorAttributes->getCurrentPage()); }
/** * Home page. * * @param Paginator $paginator * @param PaginatorAttributes $paginatorAttributes * * @return Response Response * * @Route( * path = "/{page}", * name = "store_homepage", * methods = {"GET"}, * requirements = { * "page" = "\d+", * }, * defaults = { * "page" = "1", * }, * ) * * @PaginatorAnnotation( * attributes = "paginatorAttributes", * class = "elcodi.entity.product.class", * page = "~page~", * limit = "6", * wheres = { * {"x", "enabled", "=", true}, * {"x", "showInHome", "=", true}, * }, * orderBy = { * {"x", "updatedAt", "DESC"}, * } * ) * */ public function homeAction(Paginator $paginator, PaginatorAttributes $paginatorAttributes) { return $this->renderTemplate('Pages:home-view.html.twig', ['products' => $paginator, 'currentPage' => $paginatorAttributes->getCurrentPage(), 'totalPages' => $paginatorAttributes->getTotalPages(), 'limitPerPage' => $paginatorAttributes->getLimitPerPage()]); }