diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-12-15 22:18:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-15 22:18:45 +0100 |
commit | 24becc9717423748e6ef06c6cf1c499435af66b9 (patch) | |
tree | 9d6feb77e78d8318ebccc807356ff2d414892486 /src/Wallabag/CoreBundle/Controller/EntryController.php | |
parent | 15cc1838501955638f3ac6e0fb3235bb6ac4e26c (diff) | |
parent | 6ad8aabb83581fdc978d0cea81be8e776a3b7198 (diff) | |
download | wallabag-24becc9717423748e6ef06c6cf1c499435af66b9.tar.gz wallabag-24becc9717423748e6ef06c6cf1c499435af66b9.tar.zst wallabag-24becc9717423748e6ef06c6cf1c499435af66b9.zip |
Merge pull request #2667 from wallabag/upgrade-symfony-32
Upgrade to Symfony 3.2
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 8c13255e..ff6f564e 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -23,17 +23,25 @@ class EntryController extends Controller | |||
23 | * @param Request $request | 23 | * @param Request $request |
24 | * @param int $page | 24 | * @param int $page |
25 | * | 25 | * |
26 | * @Route("/search/{page}", name="search", defaults={"page" = "1"}) | 26 | * @Route("/search/{page}", name="search", defaults={"page" = 1}) |
27 | * | ||
28 | * Default parameter for page is hardcoded (in duplication of the defaults from the Route) | ||
29 | * because this controller is also called inside the layout template without any page as argument | ||
27 | * | 30 | * |
28 | * @return \Symfony\Component\HttpFoundation\Response | 31 | * @return \Symfony\Component\HttpFoundation\Response |
29 | */ | 32 | */ |
30 | public function searchFormAction(Request $request, $page, $currentRoute) | 33 | public function searchFormAction(Request $request, $page = 1, $currentRoute = null) |
31 | { | 34 | { |
35 | // fallback to retrieve currentRoute from query parameter instead of injected one (when using inside a template) | ||
36 | if (null === $currentRoute && $request->query->has('currentRoute')) { | ||
37 | $currentRoute = $request->query->get('currentRoute'); | ||
38 | } | ||
39 | |||
32 | $form = $this->createForm(SearchEntryType::class); | 40 | $form = $this->createForm(SearchEntryType::class); |
33 | 41 | ||
34 | $form->handleRequest($request); | 42 | $form->handleRequest($request); |
35 | 43 | ||
36 | if ($form->isValid()) { | 44 | if ($form->isSubmitted() && $form->isValid()) { |
37 | return $this->showEntries('search', $request, $page); | 45 | return $this->showEntries('search', $request, $page); |
38 | } | 46 | } |
39 | 47 | ||
@@ -90,7 +98,7 @@ class EntryController extends Controller | |||
90 | 98 | ||
91 | $form->handleRequest($request); | 99 | $form->handleRequest($request); |
92 | 100 | ||
93 | if ($form->isValid()) { | 101 | if ($form->isSubmitted() && $form->isValid()) { |
94 | $existingEntry = $this->checkIfEntryAlreadyExists($entry); | 102 | $existingEntry = $this->checkIfEntryAlreadyExists($entry); |
95 | 103 | ||
96 | if (false !== $existingEntry) { | 104 | if (false !== $existingEntry) { |
@@ -173,7 +181,7 @@ class EntryController extends Controller | |||
173 | 181 | ||
174 | $form->handleRequest($request); | 182 | $form->handleRequest($request); |
175 | 183 | ||
176 | if ($form->isValid()) { | 184 | if ($form->isSubmitted() && $form->isValid()) { |
177 | $em = $this->getDoctrine()->getManager(); | 185 | $em = $this->getDoctrine()->getManager(); |
178 | $em->persist($entry); | 186 | $em->persist($entry); |
179 | $em->flush(); | 187 | $em->flush(); |
@@ -270,7 +278,7 @@ class EntryController extends Controller | |||
270 | { | 278 | { |
271 | $repository = $this->get('wallabag_core.entry_repository'); | 279 | $repository = $this->get('wallabag_core.entry_repository'); |
272 | $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : ''); | 280 | $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : ''); |
273 | $currentRoute = (!is_null($request->get('currentRoute')) ? $request->get('currentRoute') : ''); | 281 | $currentRoute = (!is_null($request->query->get('currentRoute')) ? $request->query->get('currentRoute') : ''); |
274 | 282 | ||
275 | switch ($type) { | 283 | switch ($type) { |
276 | case 'search': | 284 | case 'search': |