public function listAction(Request $request)
    {
        $current_page = $request->get('page', 1);
        $current_page = $current_page > 1 ? $current_page : 1;
        $rep = $this->getRepository();

        // filter list notice
        $filter = $this->createForm('notices_filter')->handleRequest($request);
        if ($filter->isValid()) {
            $query = $rep->getFilteredQuery($filter->getData()['status'], $filter->getData()['type']);
        } else {
            $query = $rep->createQueryBuilder('n');
        }
        $query
            ->orderBy('n.date_created', 'DESC')
            ->setFirstResult(($current_page - 1) * self::NOTICE_PER_PAGE)
            ->setMaxResults(self::NOTICE_PER_PAGE);
        $list = $query->getQuery()->getResult();

        // get count all items
        $count = $query
            ->select('COUNT(n)')
            ->getQuery()
            ->getSingleScalarResult();

        // pagination
        $that = $this;
        $request_query = $request->query->all();
        unset($request_query['page']);
        $pagination = $this->get('anime_db.pagination')
            ->create(ceil($count / self::NOTICE_PER_PAGE), $current_page)
            ->setPageLink(function ($page) use ($that, $request_query) {
                return $that->generateUrl('notice_list', array_merge($request_query, ['page' => $page]));
            })
            ->setFirstPageLink($this->generateUrl('notice_list', $request_query))
            ->getView();

        return $this->render('AnimeDbCatalogBundle:Notice:list.html.twig', [
            'list' => $list,
            'pagination' => $pagination,
            'change_form' => $this->createForm(new ChangeNotice())->createView(),
            'filter' => $filter->createView(),
            'action_remove' => ChangeNotice::ACTION_REMOVE,
        ]);
    }
public function listAction(Request $request)
    {
        $current_page = $request->get('page', 1);
        $current_page = $current_page > 1 ? $current_page : 1;
        $rep = $this->getRepository();

        // filter list notice
        $filter = $this->createForm('notices_filter')->handleRequest($request);
        if ($filter->isValid()) {
            $query = $rep->getFilteredQuery($filter->getData()['status'], $filter->getData()['type']);
        } else {
            $query = $rep->createQueryBuilder('n');
        }
        $query
            ->orderBy('n.date_created', 'DESC')
            ->setFirstResult(($current_page - 1) * self::NOTICE_PER_PAGE)
            ->setMaxResults(self::NOTICE_PER_PAGE);
        $list = $query->getQuery()->getResult();

        // get count all items
        $count = $query
            ->select('COUNT(n)')
            ->getQuery()
            ->getSingleScalarResult();

        // pagination
        $that = $this;
        $request_query = $request->query->all();
        unset($request_query['page']);
        $pagination = $this->get('anime_db.pagination')
            ->create(ceil($count / self::NOTICE_PER_PAGE), $current_page)
            ->setPageLink(function ($page) use ($that, $request_query) {
                return $that->generateUrl('notice_list', array_merge($request_query, ['page' => $page]));
            })
            ->setFirstPageLink($this->generateUrl('notice_list', $request_query))
            ->getView();

        return $this->render('AnimeDbCatalogBundle:Notice:list.html.twig', [
            'list' => $list,
            'pagination' => $pagination,
            'change_form' => $this->createForm(new ChangeNotice())->createView(),
            'filter' => $filter->createView(),
            'action_remove' => ChangeNotice::ACTION_REMOVE,
        ]);
    }
public function listAction ( Request $ request ) { $ current_page = $ request -> get ( 'page' , 1 ) ; $ current_page = $ current_page > 1 ? $ current_page : 1 ; $ rep = $ this -> getRepository ( ) ; // filter list notice $ filter = $ this -> createForm ( 'notices_filter' ) -> handleRequest ( $ request ) ; if ( $ filter -> isValid ( ) ) { $ query = $ rep -> getFilteredQuery ( $ filter -> getData ( ) [ 'status' ] , $ filter -> getData ( ) [ 'type' ] ) ; } else { $ query = $ rep -> createQueryBuilder ( 'n' ) ; } $ query -> orderBy ( 'n.date_created' , 'DESC' ) -> setFirstResult ( ( $ current_page - 1 ) * self :: NOTICE_PER_PAGE ) -> setMaxResults ( self :: NOTICE_PER_PAGE ) ; $ list = $ query -> getQuery ( ) -> getResult ( ) ; // get count all items $ count = $ query -> select ( 'COUNT(n)' ) -> getQuery ( ) -> getSingleScalarResult ( ) ; // pagination $ that = $ this ; $ request_query = $ request -> query -> all ( ) ; unset ( $ request_query [ 'page' ] ) ; $ pagination = $ this -> get ( 'anime_db.pagination' ) -> create ( ceil ( $ count / self :: NOTICE_PER_PAGE ) , $ current_page ) -> setPageLink ( function ( $ page ) use ( $ that , $ request_query ) { return $ that -> generateUrl ( 'notice_list' , array_merge ( $ request_query , [ 'page' => $ page ] ) ) ; } ) -> setFirstPageLink ( $ this -> generateUrl ( 'notice_list' , $ request_query ) ) -> getView ( ) ; return $ this -> render ( 'AnimeDbCatalogBundle:Notice:list.html.twig' , [ 'list' => $ list , 'pagination' => $ pagination , 'change_form' => $ this -> createForm ( new ChangeNotice ( ) ) -> createView ( ) , 'filter' => $ filter -> createView ( ) , 'action_remove' => ChangeNotice :: ACTION_REMOVE , ] ) ; }
Get notice list.

@param Request $request

@return Response
Get notice list .