+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'flashes.config.notice.rss_token_updated'
+ );
+
+ return $this->redirect($this->generateUrl('config').'#set2');
+ }
+
+ /**
+ * 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 RedirectResponse
+ */
+ public function deleteTaggingRuleAction(TaggingRule $rule)
+ {
+ $this->validateRuleAction($rule);
+
+ $em = $this->getDoctrine()->getManager();
+ $em->remove($rule);
+ $em->flush();
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'flashes.config.notice.tagging_rules_deleted'
+ );
+
+ return $this->redirect($this->generateUrl('config').'#set5');
+ }
+
+ /**
+ * Edit a tagging rule.
+ *
+ * @param TaggingRule $rule
+ *
+ * @Route("/tagging-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_tagging_rule")
+ *
+ * @return RedirectResponse
+ */
+ public function editTaggingRuleAction(TaggingRule $rule)
+ {
+ $this->validateRuleAction($rule);
+
+ return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5');
+ }
+
+ /**
+ * Validate that a rule can be edited/deleted by the current user.
+ *
+ * @param TaggingRule $rule
+ */
+ private function validateRuleAction(TaggingRule $rule)
+ {
+ if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
+ throw $this->createAccessDeniedException('You can not access this tagging rule.');
+ }