diff options
author | Kévin Gomez <contact@kevingomez.fr> | 2015-10-25 10:45:15 +0100 |
---|---|---|
committer | Kévin Gomez <contact@kevingomez.fr> | 2015-11-11 16:27:19 +0100 |
commit | 52e423f30761561fa2ad82c708d9fa9186562b1f (patch) | |
tree | 35bb85478b635f4e0c185f6567d9be94a60da082 | |
parent | 625acf335298186b4ff983f9321900d1238e854b (diff) | |
download | wallabag-52e423f30761561fa2ad82c708d9fa9186562b1f.tar.gz wallabag-52e423f30761561fa2ad82c708d9fa9186562b1f.tar.zst wallabag-52e423f30761561fa2ad82c708d9fa9186562b1f.zip |
Provide a way to delete tagging rules
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 27 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig | 3 |
2 files changed, 30 insertions, 0 deletions
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 | |||
@@ -189,6 +189,33 @@ class ConfigController extends Controller | |||
189 | } | 189 | } |
190 | 190 | ||
191 | /** | 191 | /** |
192 | * Deletes a tagging rule and redirect to the config homepage. | ||
193 | * | ||
194 | * @param TaggingRule $rule | ||
195 | * | ||
196 | * @Route("/tagging-rule/delete/{id}", requirements={"id" = "\d+"}, name="delete_tagging_rule") | ||
197 | * | ||
198 | * @return \Symfony\Component\HttpFoundation\RedirectResponse | ||
199 | */ | ||
200 | public function deleteTaggingRule(TaggingRule $rule) | ||
201 | { | ||
202 | if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { | ||
203 | throw $this->createAccessDeniedException('You can not access this tagging ryle.'); | ||
204 | } | ||
205 | |||
206 | $em = $this->getDoctrine()->getManager(); | ||
207 | $em->remove($rule); | ||
208 | $em->flush(); | ||
209 | |||
210 | $this->get('session')->getFlashBag()->add( | ||
211 | 'notice', | ||
212 | 'Tagging rule deleted' | ||
213 | ); | ||
214 | |||
215 | return $this->redirect($this->generateUrl('config')); | ||
216 | } | ||
217 | |||
218 | /** | ||
192 | * Retrieve config for the current user. | 219 | * Retrieve config for the current user. |
193 | * If no config were found, create a new one. | 220 | * If no config were found, create a new one. |
194 | * | 221 | * |
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 @@ | |||
191 | {% for tagging_rule in app.user.config.taggingRules %} | 191 | {% for tagging_rule in app.user.config.taggingRules %} |
192 | <li> | 192 | <li> |
193 | if « {{ tagging_rule.rule }} » then tag as « {{ tagging_rule.tags|join(', ') }} » | 193 | if « {{ tagging_rule.rule }} » then tag as « {{ tagging_rule.tags|join(', ') }} » |
194 | <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{% trans %}Delete{% endtrans %}"> | ||
195 | <i class="tool grey-text delete mdi-action-delete"></i> | ||
196 | </a> | ||
194 | </li> | 197 | </li> |
195 | {% endfor %} | 198 | {% endfor %} |
196 | </ul> | 199 | </ul> |