Esempio n. 1
0
 /**
  * @test
  */
 public function checkRtf()
 {
     $rtf = new Rtf();
     $text = $rtf->parse(__DIR__ . '/test.rtf', 2);
     $this->assertNotEmpty($text);
     //print_r($text);
 }
 /**
  *  Load tests from rtf
  *
  * @Route("/rtf", name="parser_rtf")
  * @Template()
  *
  */
 public function loadRtfAction(Request $request)
 {
     $form = $this->createForm(RtfType::class);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $data = $form->getData();
         $extension = $data['rtf']->guessExtension();
         if ($extension == "rtf") {
             $rtf = new Rtf();
             $tests = $rtf->parse($data['rtf']->getPathname(), $data['offset_line']);
             $parser = new Parser();
             $parser->setName($data['name']);
             $parser->setUrl('rtf');
             $parser->setTests($tests);
             // Save
             $entityManager = $this->getDoctrine()->getEntityManager();
             $entityManager->persist($parser);
             $entityManager->flush();
             $this->addFlash('success', 'File have parsed and saved!');
         } else {
             $this->addFlash('error', 'Wrong file format');
         }
     }
     return array('form' => $form->createView());
 }