mirror of
https://github.com/wallabag/wallabag.git
synced 2025-02-23 05:56:18 +00:00
Provide a way to delete tagging rules
This commit is contained in:
parent
625acf3352
commit
52e423f307
2 changed files with 30 additions and 0 deletions
|
@ -188,6 +188,33 @@ class ConfigController extends Controller
|
||||||
return $request->headers->get('referer') ? $this->redirect($request->headers->get('referer')) : $this->redirectToRoute('config');
|
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.
|
* Retrieve config for the current user.
|
||||||
* If no config were found, create a new one.
|
* If no config were found, create a new one.
|
||||||
|
|
|
@ -191,6 +191,9 @@
|
||||||
{% for tagging_rule in app.user.config.taggingRules %}
|
{% for tagging_rule in app.user.config.taggingRules %}
|
||||||
<li>
|
<li>
|
||||||
if « {{ tagging_rule.rule }} » then tag as « {{ tagging_rule.tags|join(', ') }} »
|
if « {{ tagging_rule.rule }} » then tag as « {{ tagging_rule.tags|join(', ') }} »
|
||||||
|
<a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{% trans %}Delete{% endtrans %}">
|
||||||
|
<i class="tool grey-text delete mdi-action-delete"></i>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in a new issue