mirror of
https://github.com/wallabag/wallabag.git
synced 2025-06-27 16:36:00 +00:00
Add ability to reset some datas
- annotations - tags - entries
This commit is contained in:
parent
e8331dd9e7
commit
206bade58a
18 changed files with 406 additions and 22 deletions
|
@ -224,6 +224,48 @@ class ConfigController extends Controller
|
|||
return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all annotations OR tags OR entries for the current user.
|
||||
*
|
||||
* @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries"}, name="config_reset")
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function resetAction($type)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
switch ($type) {
|
||||
case 'annotations':
|
||||
$em->createQuery('DELETE FROM Wallabag\AnnotationBundle\Entity\Annotation a WHERE a.user = '.$this->getUser()->getId())
|
||||
->execute();
|
||||
break;
|
||||
|
||||
case 'tags':
|
||||
$tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findAllTags($this->getUser()->getId());
|
||||
|
||||
if (empty($tags)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$this->getDoctrine()
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->removeTags($this->getUser()->getId(), $tags);
|
||||
break;
|
||||
|
||||
case 'entries':
|
||||
$em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.user = '.$this->getUser()->getId())
|
||||
->execute();
|
||||
}
|
||||
|
||||
$this->get('session')->getFlashBag()->add(
|
||||
'notice',
|
||||
'flashes.config.notice.'.$type.'_reset'
|
||||
);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'#set3');
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a rule can be edited/deleted by the current user.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue