0

見て {{ knp_pagination_render(pagination1) }}いますInfCustumersBundle:Faktura:indexoryginal.html.twig

このコードはページナリオンを示しています:

public function indexoryginalAction(Request $request) {              
            $em = $this->getDoctrine()->getManager();
            $req = $em->getRepository('...:Faktura');
            $qb = $req->createQueryBuilder('p');
            $search = $qb
                        .
            .
                    ->getQuery();              
           $form = $this->createFormBuilder()
               .
           .
                ->getForm();
        $paginator = $this->get('knp_paginator');
        $pagination1 = $paginator->paginate(
                $search, $request->query->get('page', 1)/* page number */, 5/* limit per page */
        );

        return $this->render('InfCustumersBundle:Faktura:indexoryginal.html.twig', array(
                    'pagination1' => $pagination1,
                    'form' => $form->createView()
        ));

これはうまくいきますが、以下のコードはページネーションタグを表示しません。最初の3項目のみ。どこで間違えたのですか?

public function indexAction(Request $request, $type = 1) {

        $data = array();
        $form = $this->createFormBuilder()
                .
        .   
                ->getForm();
        if ($request->isMethod('GET')) {
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
            $data = $form->getData();
                    $name = ($data['for'] == 'name' ? true : false);
                if ($name) {
                    return $this->Name($form);
                } 
            }          
                return $this->redirect($this->generateUrl('faktura_oryginal', array(
                                    $this->get('session')->getFlashBag()->add('error', 'error')
                )));          
        }

protected function Name($form) {

        $em2 = $this->getDoctrine()->getManager();
        $req = $em2->getRepository('InfCustomersBundle:Faktura');
        $qb = $req->createQueryBuilder('p');

        $query2 = $qb
                .
                .
                ->getQuery();

        $entities2 = $query2->getResult();
        if ($entities2) {

            $paginator = $this->get('knp_paginator');
            $request = $this->get('request_stack');
            //  $request = $this->getRequest();
            $pagination1 = $paginator->paginate(
                    $query2, $request->getCurrentRequest()->query->get('page', 1)/* page number */, 3/* limit per page */
            );          
                return $this->render('InfCustumersBundle:Faktura:indexoryginal.html.twig', array(
                            'pagination1' => $pagination1,
                            'form' => $form->createView()
                ));          
        } else {
                return $this->redirect($this->generateUrl('faktura_oryginal', array(                               $this->get('session')->getFlashBag()->add('error', 'error')
                )));         
            }
        }
    }
4

1 に答える 1