aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/EntryController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php35
1 files changed, 33 insertions, 2 deletions
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,10 +15,35 @@ use Wallabag\CoreBundle\Form\Type\NewEntryType;
15use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; 15use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
16use Wallabag\CoreBundle\Event\EntrySavedEvent; 16use Wallabag\CoreBundle\Event\EntrySavedEvent;
17use Wallabag\CoreBundle\Event\EntryDeletedEvent; 17use Wallabag\CoreBundle\Event\EntryDeletedEvent;
18use Wallabag\CoreBundle\Form\Type\SearchEntryType;
18 19
19class EntryController extends Controller 20class EntryController extends Controller
20{ 21{
21 /** 22 /**
23 * @param Request $request
24 * @param int $page
25 *
26 * @Route("/search/{page}", name="search", defaults={"page" = "1"})
27 *
28 * @return \Symfony\Component\HttpFoundation\Response
29 */
30 public function searchFormAction(Request $request, $page, $currentRoute)
31 {
32 $form = $this->createForm(SearchEntryType::class);
33
34 $form->handleRequest($request);
35
36 if ($form->isValid()) {
37 return $this->showEntries('search', $request, $page);
38 }
39
40 return $this->render('WallabagCoreBundle:Entry:search_form.html.twig', [
41 'form' => $form->createView(),
42 'currentRoute' => $currentRoute,
43 ]);
44 }
45
46 /**
22 * Fetch content and update entry. 47 * Fetch content and update entry.
23 * In case it fails, entry will return to avod loosing the data. 48 * In case it fails, entry will return to avod loosing the data.
24 * 49 *
@@ -244,8 +269,14 @@ class EntryController extends Controller
244 private function showEntries($type, Request $request, $page) 269 private function showEntries($type, Request $request, $page)
245 { 270 {
246 $repository = $this->get('wallabag_core.entry_repository'); 271 $repository = $this->get('wallabag_core.entry_repository');
272 $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
273 $currentRoute = (!is_null($request->get('currentRoute')) ? $request->get('currentRoute') : '');
247 274
248 switch ($type) { 275 switch ($type) {
276 case 'search':
277 $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
278
279 break;
249 case 'untagged': 280 case 'untagged':
250 $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId()); 281 $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId());
251 282
@@ -294,11 +325,11 @@ class EntryController extends Controller
294 } 325 }
295 326
296 return $this->render( 327 return $this->render(
297 'WallabagCoreBundle:Entry:entries.html.twig', 328 'WallabagCoreBundle:Entry:entries.html.twig', [
298 [
299 'form' => $form->createView(), 329 'form' => $form->createView(),
300 'entries' => $entries, 330 'entries' => $entries,
301 'currentPage' => $page, 331 'currentPage' => $page,
332 'searchTerm' => $searchTerm,
302 ] 333 ]
303 ); 334 );
304 } 335 }