aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2015-02-04 17:54:23 +0100
committerNicolas Lœuillet <nicolas@loeuillet.org>2015-02-04 17:54:23 +0100
commit42a9064620eb73eaa42928a22eeec86299d4a883 (patch)
tree59f24a86bcde7f497a860300e299b87e7af13d43 /src/Wallabag/CoreBundle/Controller
parent889249804f44136fc608bbc6699f47932825d440 (diff)
downloadwallabag-42a9064620eb73eaa42928a22eeec86299d4a883.tar.gz
wallabag-42a9064620eb73eaa42928a22eeec86299d4a883.tar.zst
wallabag-42a9064620eb73eaa42928a22eeec86299d4a883.zip
implement delete method
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php3
-rw-r--r--src/Wallabag/CoreBundle/Controller/WallabagRestController.php13
2 files changed, 15 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 377a45ae..eb5b43ad 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -177,7 +177,8 @@ class EntryController extends Controller
177 public function deleteEntryAction(Request $request, Entries $entry) 177 public function deleteEntryAction(Request $request, Entries $entry)
178 { 178 {
179 $em = $this->getDoctrine()->getManager(); 179 $em = $this->getDoctrine()->getManager();
180 $em->remove($entry); 180 $entry->setDeleted(1);
181 $em->persist($entry);
181 $em->flush(); 182 $em->flush();
182 183
183 $this->get('session')->getFlashBag()->add( 184 $this->get('session')->getFlashBag()->add(
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
index 5668d934..fc13b1a8 100644
--- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
@@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Controller;
5use Nelmio\ApiDocBundle\Annotation\ApiDoc; 5use Nelmio\ApiDocBundle\Annotation\ApiDoc;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
8use Wallabag\CoreBundle\Entity\Entries; 9use Wallabag\CoreBundle\Entity\Entries;
9use Wallabag\CoreBundle\Entity\Tags; 10use Wallabag\CoreBundle\Entity\Tags;
10use Wallabag\CoreBundle\Service\Extractor; 11use Wallabag\CoreBundle\Service\Extractor;
@@ -30,6 +31,8 @@ class WallabagRestController extends Controller
30 */ 31 */
31 public function getEntriesAction(Request $request) 32 public function getEntriesAction(Request $request)
32 { 33 {
34 // TODO isArchived, isStarred et isDeleted ne doivent pas avoir de valeur par défaut
35 // TODO Si on ne passe rien, on ne filtre pas sur le statut.
33 $isArchived = $request->query->get('archive', 0); 36 $isArchived = $request->query->get('archive', 0);
34 $isStarred = $request->query->get('star', 0); 37 $isStarred = $request->query->get('star', 0);
35 $isDeleted = $request->query->get('delete', 0); 38 $isDeleted = $request->query->get('delete', 0);
@@ -129,6 +132,16 @@ class WallabagRestController extends Controller
129 */ 132 */
130 public function deleteEntriesAction(Entries $entry) 133 public function deleteEntriesAction(Entries $entry)
131 { 134 {
135 if ($entry->isDeleted()) {
136 throw new NotFoundHttpException('This entry is already deleted');
137 }
138
139 $em = $this->getDoctrine()->getManager();
140 $entry->setDeleted(1);
141 $em->persist($entry);
142 $em->flush();
143
144 return $entry;
132 } 145 }
133 146
134 /** 147 /**