diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-01 09:26:32 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-22 13:13:06 +0200 |
commit | 206bade58a279d7f2e34c2dbada10366b90d2d6b (patch) | |
tree | 6c5fc1fe65dfa9e661a09b3fd92253f2931b84de /src/Wallabag/CoreBundle/Controller/ConfigController.php | |
parent | e8331dd9e7772a396bb211459eca4a682c8e947e (diff) | |
download | wallabag-206bade58a279d7f2e34c2dbada10366b90d2d6b.tar.gz wallabag-206bade58a279d7f2e34c2dbada10366b90d2d6b.tar.zst wallabag-206bade58a279d7f2e34c2dbada10366b90d2d6b.zip |
Add ability to reset some datas
- annotations
- tags
- entries
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ConfigController.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index abd35c02..ccbf550a 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -225,6 +225,48 @@ class ConfigController extends Controller | |||
225 | } | 225 | } |
226 | 226 | ||
227 | /** | 227 | /** |
228 | * Remove all annotations OR tags OR entries for the current user. | ||
229 | * | ||
230 | * @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries"}, name="config_reset") | ||
231 | * | ||
232 | * @return RedirectResponse | ||
233 | */ | ||
234 | public function resetAction($type) | ||
235 | { | ||
236 | $em = $this->getDoctrine()->getManager(); | ||
237 | |||
238 | switch ($type) { | ||
239 | case 'annotations': | ||
240 | $em->createQuery('DELETE FROM Wallabag\AnnotationBundle\Entity\Annotation a WHERE a.user = '.$this->getUser()->getId()) | ||
241 | ->execute(); | ||
242 | break; | ||
243 | |||
244 | case 'tags': | ||
245 | $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findAllTags($this->getUser()->getId()); | ||
246 | |||
247 | if (empty($tags)) { | ||
248 | break; | ||
249 | } | ||
250 | |||
251 | $this->getDoctrine() | ||
252 | ->getRepository('WallabagCoreBundle:Entry') | ||
253 | ->removeTags($this->getUser()->getId(), $tags); | ||
254 | break; | ||
255 | |||
256 | case 'entries': | ||
257 | $em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.user = '.$this->getUser()->getId()) | ||
258 | ->execute(); | ||
259 | } | ||
260 | |||
261 | $this->get('session')->getFlashBag()->add( | ||
262 | 'notice', | ||
263 | 'flashes.config.notice.'.$type.'_reset' | ||
264 | ); | ||
265 | |||
266 | return $this->redirect($this->generateUrl('config').'#set3'); | ||
267 | } | ||
268 | |||
269 | /** | ||
228 | * Validate that a rule can be edited/deleted by the current user. | 270 | * Validate that a rule can be edited/deleted by the current user. |
229 | * | 271 | * |
230 | * @param TaggingRule $rule | 272 | * @param TaggingRule $rule |