X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FEntryController.php;h=9ed1cb12699c37940340ab47a23f30d71747f29f;hb=21e7ccef3d960f4747d58fc0c9e081618e9451eb;hp=8c13255ec70bd9fabe44fc7b99cd84f4603425d6;hpb=202a66ce02bf42743e66fbc1ea1dbfe5b6a1c83a;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 8c13255e..9ed1cb12 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -23,17 +23,25 @@ class EntryController extends Controller * @param Request $request * @param int $page * - * @Route("/search/{page}", name="search", defaults={"page" = "1"}) + * @Route("/search/{page}", name="search", defaults={"page" = 1}) + * + * Default parameter for page is hardcoded (in duplication of the defaults from the Route) + * because this controller is also called inside the layout template without any page as argument * * @return \Symfony\Component\HttpFoundation\Response */ - public function searchFormAction(Request $request, $page, $currentRoute) + public function searchFormAction(Request $request, $page = 1, $currentRoute = null) { + // fallback to retrieve currentRoute from query parameter instead of injected one (when using inside a template) + if (null === $currentRoute && $request->query->has('currentRoute')) { + $currentRoute = $request->query->get('currentRoute'); + } + $form = $this->createForm(SearchEntryType::class); $form->handleRequest($request); - if ($form->isValid()) { + if ($form->isSubmitted() && $form->isValid()) { return $this->showEntries('search', $request, $page); } @@ -90,7 +98,7 @@ class EntryController extends Controller $form->handleRequest($request); - if ($form->isValid()) { + if ($form->isSubmitted() && $form->isValid()) { $existingEntry = $this->checkIfEntryAlreadyExists($entry); if (false !== $existingEntry) { @@ -173,7 +181,7 @@ class EntryController extends Controller $form->handleRequest($request); - if ($form->isValid()) { + if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($entry); $em->flush();