+ /**
+ * @param Request $request
+ *
+ * @Route("/generate-token", name="generate_token")
+ *
+ * @return JsonResponse
+ */
+ public function generateTokenAction(Request $request)
+ {
+ $config = $this->getConfig();
+ $config->setRssToken(Utils::generateToken());
+
+ $em = $this->getDoctrine()->getManager();
+ $em->persist($config);
+ $em->flush();
+
+ if ($request->isXmlHttpRequest()) {
+ return new JsonResponse(array('token' => $config->getRssToken()));
+ }
+
+ 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'));
+ }
+