+ * @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 = 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->isSubmitted() && $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.
+ *
+ * @param Entry $entry
+ * @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded
+ *
+ * @return Entry
+ */
+ private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved')
+ {
+ // put default title in case of fetching content failed
+ $entry->setTitle('No title found');
+
+ $message = 'flashes.entry.notice.'.$prefixMessage;
+
+ try {
+ $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
+ } catch (\Exception $e) {
+ $this->get('logger')->error('Error while saving an entry', [
+ 'exception' => $e,
+ 'entry' => $entry,
+ ]);
+
+ $message = 'flashes.entry.notice.'.$prefixMessage.'_failed';
+ }
+
+ $this->get('session')->getFlashBag()->add('notice', $message);
+
+ return $entry;
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @Route("/new-entry", name="new_entry")