From 52e423f30761561fa2ad82c708d9fa9186562b1f Mon Sep 17 00:00:00 2001 From: =?utf8?q?K=C3=A9vin=20Gomez?= Date: Sun, 25 Oct 2015 10:45:15 +0100 Subject: [PATCH] Provide a way to delete tagging rules --- .../Controller/ConfigController.php | 27 +++++++++++++++++++ .../themes/material/Config/index.html.twig | 3 +++ 2 files changed, 30 insertions(+) diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 24b86344..de1536c9 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -188,6 +188,33 @@ class ConfigController extends Controller return $request->headers->get('referer') ? $this->redirect($request->headers->get('referer')) : $this->redirectToRoute('config'); } + /** + * Deletes a tagging rule and redirect to the config homepage. + * + * @param TaggingRule $rule + * + * @Route("/tagging-rule/delete/{id}", requirements={"id" = "\d+"}, name="delete_tagging_rule") + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function deleteTaggingRule(TaggingRule $rule) + { + if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { + throw $this->createAccessDeniedException('You can not access this tagging ryle.'); + } + + $em = $this->getDoctrine()->getManager(); + $em->remove($rule); + $em->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'Tagging rule deleted' + ); + + return $this->redirect($this->generateUrl('config')); + } + /** * Retrieve config for the current user. * If no config were found, create a new one. diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index 993c5826..1457fe51 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -191,6 +191,9 @@ {% for tagging_rule in app.user.config.taggingRules %}
  • if « {{ tagging_rule.rule }} » then tag as « {{ tagging_rule.tags|join(', ') }} » + + +
  • {% endfor %} -- 2.41.0