X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FEntryController.php;h=8c13255ec70bd9fabe44fc7b99cd84f4603425d6;hb=1093e979ff49f9072c30d1d576c6adf1f8e76bdf;hp=3f4eb17d1fbacc5b4e350b431fee6c9a4b6505c9;hpb=e0597476d1d5f6a4a7d6ea9b76966465f3d22fb8;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 3f4eb17d..8c13255e 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -15,9 +15,34 @@ use Wallabag\CoreBundle\Form\Type\NewEntryType; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; use Wallabag\CoreBundle\Event\EntrySavedEvent; use Wallabag\CoreBundle\Event\EntryDeletedEvent; +use Wallabag\CoreBundle\Form\Type\SearchEntryType; class EntryController extends Controller { + /** + * @param Request $request + * @param int $page + * + * @Route("/search/{page}", name="search", defaults={"page" = "1"}) + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function searchFormAction(Request $request, $page, $currentRoute) + { + $form = $this->createForm(SearchEntryType::class); + + $form->handleRequest($request); + + if ($form->isValid()) { + return $this->showEntries('search', $request, $page); + } + + return $this->render('WallabagCoreBundle:Entry:search_form.html.twig', [ + 'form' => $form->createView(), + 'currentRoute' => $currentRoute, + ]); + } + /** * Fetch content and update entry. * In case it fails, entry will return to avod loosing the data. @@ -244,8 +269,14 @@ class EntryController extends Controller private function showEntries($type, Request $request, $page) { $repository = $this->get('wallabag_core.entry_repository'); + $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : ''); + $currentRoute = (!is_null($request->get('currentRoute')) ? $request->get('currentRoute') : ''); switch ($type) { + case 'search': + $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute); + + break; case 'untagged': $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId()); @@ -294,11 +325,11 @@ class EntryController extends Controller } return $this->render( - 'WallabagCoreBundle:Entry:entries.html.twig', - [ + 'WallabagCoreBundle:Entry:entries.html.twig', [ 'form' => $form->createView(), 'entries' => $entries, 'currentPage' => $page, + 'searchTerm' => $searchTerm, ] ); }