Ejemplo n.º 1
0
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $parser = new LogParser();
     foreach ($this->usersFiles as $file => $user) {
         $logs = $parser->parseFile(realpath($file), $user);
         array_map(function ($log) use($em) {
             $em->persist($log);
         }, $logs);
     }
     $em->flush();
 }
Ejemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $username = $input->getArgument('username');
     $parser = new LogParser();
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     $logDir = $this->getUserLogDir($username);
     if (false === scandir($logDir)) {
         throw new InvalidArgumentException(sprintf('"%s" directory does not exists', $logDir));
     }
     foreach ($this->getFiles($logDir) as $file) {
         $lastLogStamp = $em->getRepository('AppBundle:Log')->getLastStamp($file);
         $logs = $parser->parseFile($file, $username, $lastLogStamp);
         array_map(function ($log) use($em) {
             $em->persist($log);
         }, $logs);
     }
     $em->flush();
 }
Ejemplo n.º 3
0
 public function testParseFile()
 {
     $parser = new LogParser();
     $this->assertCount(3, $parser->parseFile(realpath(__DIR__ . '/test.log'), 'test'));
     $this->assertCount(2, $parser->parseFile(realpath(__DIR__ . '/test.log'), 'test', 1448118000));
 }