]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
filters: adapt queryBuilder for 'all' view
authorNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 21 Aug 2015 05:38:18 +0000 (07:38 +0200)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 21 Aug 2015 05:38:18 +0000 (07:38 +0200)
src/Wallabag/CoreBundle/Controller/EntryController.php
src/Wallabag/CoreBundle/Repository/EntryRepository.php

index 4070a6037d0ab0174fc8504756dd2575dbf54d69..c4975ae6673cd44aed00ace982e05b1cd47c2c36 100644 (file)
@@ -113,34 +113,7 @@ class EntryController extends Controller
      */
     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,
-            )
-        );
+        return $this->showEntries('all', $request, $page);
     }
 
     /**
@@ -215,6 +188,10 @@ class EntryController extends Controller
                 $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
                 break;
 
+            case 'all':
+                $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
+                break;
+
             default:
                 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
         }
index 5538ae82b40081101d2482271a7b0b290039bfbf..e764e8f707e6566e2fcdec8914ae286904a930f6 100644 (file)
@@ -24,6 +24,20 @@ class EntryRepository extends EntityRepository
         ;
     }
 
+    /**
+     * Retrieves all entries for a user.
+     *
+     * @param int $userId
+     *
+     * @return QueryBuilder
+     */
+    public function getBuilderForAllByUser($userId)
+    {
+        return $this
+            ->getBuilderByUser($userId)
+        ;
+    }
+
     /**
      * Retrieves unread entries for a user.
      *