diff options
Diffstat (limited to 'src')
4 files changed, 42 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; | |||
5 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; | 5 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
8 | use Wallabag\CoreBundle\Entity\Entries; | 9 | use Wallabag\CoreBundle\Entity\Entries; |
9 | use Wallabag\CoreBundle\Entity\Tags; | 10 | use Wallabag\CoreBundle\Entity\Tags; |
10 | use Wallabag\CoreBundle\Service\Extractor; | 11 | use 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 | /** |
diff --git a/src/Wallabag/CoreBundle/Entity/Entries.php b/src/Wallabag/CoreBundle/Entity/Entries.php index 9da5102c..32e928d2 100644 --- a/src/Wallabag/CoreBundle/Entity/Entries.php +++ b/src/Wallabag/CoreBundle/Entity/Entries.php | |||
@@ -67,6 +67,13 @@ class Entries | |||
67 | private $userId; | 67 | private $userId; |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * @var string | ||
71 | * | ||
72 | * @ORM\Column(name="is_deleted", type="decimal", precision=10, scale=0, nullable=true) | ||
73 | */ | ||
74 | private $isDeleted = '0'; | ||
75 | |||
76 | /** | ||
70 | * Get id | 77 | * Get id |
71 | * | 78 | * |
72 | * @return integer | 79 | * @return integer |
@@ -227,4 +234,20 @@ class Entries | |||
227 | { | 234 | { |
228 | return $this->userId; | 235 | return $this->userId; |
229 | } | 236 | } |
237 | |||
238 | /** | ||
239 | * @return string | ||
240 | */ | ||
241 | public function isDeleted() | ||
242 | { | ||
243 | return $this->isDeleted; | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | * @param string $isDeleted | ||
248 | */ | ||
249 | public function setDeleted($isDeleted) | ||
250 | { | ||
251 | $this->isDeleted = $isDeleted; | ||
252 | } | ||
230 | } | 253 | } |
diff --git a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php index d87eb373..c76b4215 100644 --- a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php | |||
@@ -25,6 +25,7 @@ class EntriesRepository extends EntityRepository | |||
25 | ->setMaxResults($maxResults) | 25 | ->setMaxResults($maxResults) |
26 | ->where('e.isRead = 0') | 26 | ->where('e.isRead = 0') |
27 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 27 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
28 | ->andWhere('e.isDeleted=0') | ||
28 | ->getQuery(); | 29 | ->getQuery(); |
29 | 30 | ||
30 | $paginator = new Paginator($qb); | 31 | $paginator = new Paginator($qb); |
@@ -48,6 +49,7 @@ class EntriesRepository extends EntityRepository | |||
48 | ->setMaxResults($maxResults) | 49 | ->setMaxResults($maxResults) |
49 | ->where('e.isRead = 1') | 50 | ->where('e.isRead = 1') |
50 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 51 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
52 | ->andWhere('e.isDeleted=0') | ||
51 | ->getQuery(); | 53 | ->getQuery(); |
52 | 54 | ||
53 | $paginator = new Paginator($qb); | 55 | $paginator = new Paginator($qb); |
@@ -71,6 +73,7 @@ class EntriesRepository extends EntityRepository | |||
71 | ->setMaxResults($maxResults) | 73 | ->setMaxResults($maxResults) |
72 | ->where('e.isFav = 1') | 74 | ->where('e.isFav = 1') |
73 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 75 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
76 | ->andWhere('e.isDeleted=0') | ||
74 | ->getQuery(); | 77 | ->getQuery(); |
75 | 78 | ||
76 | $paginator = new Paginator($qb); | 79 | $paginator = new Paginator($qb); |
@@ -86,6 +89,7 @@ class EntriesRepository extends EntityRepository | |||
86 | ->where('e.isFav =:isStarred')->setParameter('isStarred', $isStarred) | 89 | ->where('e.isFav =:isStarred')->setParameter('isStarred', $isStarred) |
87 | ->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived) | 90 | ->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived) |
88 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | 91 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) |
92 | ->andWhere('e.isDeleted=0') | ||
89 | ->getQuery() | 93 | ->getQuery() |
90 | ->getResult(Query::HYDRATE_ARRAY); | 94 | ->getResult(Query::HYDRATE_ARRAY); |
91 | 95 | ||