diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2020-04-12 16:31:12 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2020-04-24 09:12:57 +0200 |
commit | 467327771aea031c0ad6e7ab0e8f5a97ba69a8e2 (patch) | |
tree | 43b1ec77eeb062ee618f017a3dc09cd42491c695 /src/Wallabag/CoreBundle/Controller/EntryController.php | |
parent | 31e3a233a457ee986d1cb347f7d02752159d5750 (diff) | |
download | wallabag-467327771aea031c0ad6e7ab0e8f5a97ba69a8e2.tar.gz wallabag-467327771aea031c0ad6e7ab0e8f5a97ba69a8e2.tar.zst wallabag-467327771aea031c0ad6e7ab0e8f5a97ba69a8e2.zip |
Added mass actions for Material design in list view
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index ba5bfbe2..9b2954e7 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -21,6 +21,48 @@ use Wallabag\CoreBundle\Form\Type\SearchEntryType; | |||
21 | class EntryController extends Controller | 21 | class EntryController extends Controller |
22 | { | 22 | { |
23 | /** | 23 | /** |
24 | * @Route("/mass", name="mass_action") | ||
25 | * | ||
26 | * @return \Symfony\Component\HttpFoundation\Response | ||
27 | */ | ||
28 | public function massAction(Request $request) | ||
29 | { | ||
30 | $em = $this->getDoctrine()->getManager(); | ||
31 | $values = $request->request->all(); | ||
32 | |||
33 | $action = 'toggle-read'; | ||
34 | if (isset($values['toggle-star'])) { | ||
35 | $action = 'toggle-star'; | ||
36 | } elseif (isset($values['delete'])) { | ||
37 | $action = 'delete'; | ||
38 | } | ||
39 | |||
40 | if (isset($values['entry-checkbox'])) { | ||
41 | foreach ($values['entry-checkbox'] as $id) { | ||
42 | /** @var Entry * */ | ||
43 | $entry = $this->get('wallabag_core.entry_repository')->findById((int) $id)[0]; | ||
44 | |||
45 | $this->checkUserAction($entry); | ||
46 | |||
47 | if ('toggle-read' === $action) { | ||
48 | $entry->toggleArchive(); | ||
49 | } elseif ('toggle-star' === $action) { | ||
50 | $entry->toggleStar(); | ||
51 | } elseif ('delete' === $action) { | ||
52 | $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); | ||
53 | $em->remove($entry); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | $em->flush(); | ||
58 | } | ||
59 | |||
60 | $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer')); | ||
61 | |||
62 | return $this->redirect($redirectUrl); | ||
63 | } | ||
64 | |||
65 | /** | ||
24 | * @param int $page | 66 | * @param int $page |
25 | * | 67 | * |
26 | * @Route("/search/{page}", name="search", defaults={"page" = 1}) | 68 | * @Route("/search/{page}", name="search", defaults={"page" = 1}) |