]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/EntryController.php
filters: implement status filter and a new view (to display all entries)
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / EntryController.php
index dc399b8a3289ef58a9b835831eeb2d30b50b66c8..4070a6037d0ab0174fc8504756dd2575dbf54d69 100644 (file)
@@ -101,6 +101,48 @@ class EntryController extends Controller
         ));
     }
 
+    /**
+     * Shows all entries for current user.
+     *
+     * @param Request $request
+     * @param int     $page
+     *
+     * @Route("/all/list/{page}", name="all", defaults={"page" = "1"})
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function showAllAction(Request $request, $page)
+    {
+        $form = $this->get('form.factory')->create(new EntryFilterType());
+
+        $filterBuilder = $this->getDoctrine()
+            ->getRepository('WallabagCoreBundle:Entry')
+            ->findAllByUser($this->getUser()->getId());
+
+        if ($request->query->has($form->getName())) {
+            // manually bind values from the request
+            $form->submit($request->query->get($form->getName()));
+
+            // build the query from the given form object
+            $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder);
+        }
+
+        $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery());
+        $entries = new Pagerfanta($pagerAdapter);
+
+        $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
+        $entries->setCurrentPage($page);
+
+        return $this->render(
+            'WallabagCoreBundle:Entry:entries.html.twig',
+            array(
+                'form' => $form->createView(),
+                'entries' => $entries,
+                'currentPage' => $page,
+            )
+        );
+    }
+
     /**
      * Shows unread entries for current user.
      *