* @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);
}
$form->handleRequest($request);
- if ($form->isValid()) {
+ if ($form->isSubmitted() && $form->isValid()) {
$existingEntry = $this->checkIfEntryAlreadyExists($entry);
if (false !== $existingEntry) {
$form->handleRequest($request);
- if ($form->isValid()) {
+ if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
$em->flush();
{
$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') : '');
+ $currentRoute = (!is_null($request->query->get('currentRoute')) ? $request->query->get('currentRoute') : '');
switch ($type) {
case 'search':
$this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
}
- $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
+ $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
$entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')
->prepare($pagerAdapter, $page);
{
$this->checkUserAction($entry);
- if (null === $entry->getUuid()) {
- $entry->generateUuid();
+ if (null === $entry->getUid()) {
+ $entry->generateUid();
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
}
return $this->redirect($this->generateUrl('share_entry', [
- 'uuid' => $entry->getUuid(),
+ 'uid' => $entry->getUid(),
]));
}
{
$this->checkUserAction($entry);
- $entry->cleanUuid();
+ $entry->cleanUid();
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
*
* @param Entry $entry
*
- * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry")
+ * @Route("/share/{uid}", requirements={"uid" = ".+"}, name="share_entry")
* @Cache(maxage="25200", smaxage="25200", public=true)
*
* @return \Symfony\Component\HttpFoundation\Response