/**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $tr1 = new TaggingRule();
     $tr1->setRule('content matches "spurs"');
     $tr1->setTags(['sport']);
     $tr1->setConfig($this->getReference('admin-config'));
     $manager->persist($tr1);
     $tr2 = new TaggingRule();
     $tr2->setRule('content matches "basket"');
     $tr2->setTags(['sport']);
     $tr2->setConfig($this->getReference('admin-config'));
     $manager->persist($tr2);
     $tr3 = new TaggingRule();
     $tr3->setRule('title matches "wallabag"');
     $tr3->setTags(['wallabag']);
     $tr3->setConfig($this->getReference('admin-config'));
     $manager->persist($tr3);
     $manager->flush();
 }
 /**
  * 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.');
     }
 }
 /**
  * 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)
 {
     if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
         throw $this->createAccessDeniedException('You can not access this tagging 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');
 }
 private function getTaggingRule($rule, array $tags)
 {
     $taggingRule = new TaggingRule();
     $taggingRule->setRule($rule);
     $taggingRule->setTags($tags);
     return $taggingRule;
 }