public function findAllByRule(\Swd\AnalyzerBundle\Entity\BlacklistRule $rule)
 {
     $builder = $this->createQueryBuilder('wr')->andWhere('wr.profile = :profile')->setParameter('profile', $rule->getProfile())->andWhere('wr.caller = :caller')->setParameter('caller', $rule->getCaller())->andWhere('wr.path = :path')->setParameter('path', $rule->getPath())->andWhere('wr.minLength = :minLength')->setParameter('minLength', $rule->getMinLength())->andWhere('wr.maxLength = :maxLength')->setParameter('maxLength', $rule->getMaxLength())->andWhere('wr.filter = :filter')->setParameter('filter', $rule->getFilter());
     return $builder->getQuery();
 }
 /**
  * @Security("has_role('ROLE_ADMIN')")
  */
 public function importAction()
 {
     /* Handle form. */
     $import = new BlacklistImport();
     $form = $this->createForm(new BlacklistImportType(), $import);
     $form->handleRequest($this->get('request'));
     /* Insert and redirect or show the form. */
     if ($form->isValid()) {
         $fileContent = file_get_contents($import->getFile()->getPathName());
         $rules = json_decode($fileContent, true);
         if ($rules) {
             $em = $this->getDoctrine()->getManager();
             foreach ($rules as $rule) {
                 $ruleObj = new BlacklistRule();
                 $ruleObj->setProfile($import->getProfile());
                 $ruleObj->setPath($rule['path']);
                 $ruleObj->setCaller(str_replace('{BASE}', $import->getBase(), $rule['caller']));
                 $ruleObj->setThreshold($rule['threshold']);
                 $ruleObj->setStatus(3);
                 $em->persist($ruleObj);
             }
             $em->flush();
             $this->get('session')->getFlashBag()->add('info', 'The rules were imported.');
         } else {
             $this->get('session')->getFlashBag()->add('alert', 'Invalid file.');
         }
         return $this->redirect($this->generateUrl('swd_analyzer_blacklist_rules'));
     } else {
         /* Render template. */
         return $this->render('SwdAnalyzerBundle:Blacklist:import.html.twig', array('form' => $form->createView()));
     }
 }