protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (is_file($input->getArgument('content')) && is_readable($input->getArgument('content'))) {
         $content = file_get_contents($input->getArgument('content'));
     } else {
         $content = $input->getArgument('content');
     }
     $em = $this->getContainer()->get('doctrine')->getManager();
     $am = $this->getContainer()->get('gitpushwatcher.author_manager');
     # Extraction des auteurs des commits
     $am->extractAuthors($content);
     $push = new Push();
     $push->setPath($input->getArgument('path'));
     $push->setProject($input->getArgument('project'));
     $push->setSubject($input->getArgument('subject'));
     $push->setText($content);
     $em->persist($push);
     $em->flush();
     $output->writeln('Inserting into logger.');
     # Notification
     $notifier_name = $this->getContainer()->getParameter('mrk_git_push_watcher.notifier_service');
     if ($this->getContainer()->has($notifier_name)) {
         /**
          * @var Mrk\GitPushWatcherBundle\Notifier\NotifierInterface $notifier
          */
         $notifier = $this->getContainer()->get($notifier_name);
         $notifier->setMessage($push->getSubject(), $push->getText());
         $notifier->notify();
         $output->writeln('Notify.');
     }
 }
예제 #2
0
 public function load(ObjectManager $manager)
 {
     $authors = ['Marc Teinturier <*****@*****.**>', 'Lemmy Killmister <*****@*****.**>', 'Jimi Hendrix <*****@*****.**>', 'Kurt Cobain <*****@*****.**>', 'Janis Joplin <*****@*****.**>', 'David Bowie <*****@*****.**>', 'Jim Morrison <*****@*****.**>'];
     $projects = ['www.rockstar.com', 'www.inhaeven.com', 'www.omg.com', 'www.fender.com', 'www.gibson.com', 'www.rocker.com'];
     $path_root = '/var/www/';
     //$am         = $this->container->get('gitpushwatcher.author_manager');
     for ($i = 0; $i < 200; $i++) {
         $datetime = new \DateTime();
         $datetime->setTimestamp(time() - rand(0, 30 * 24 * 60 * 60));
         //echo $date->format("Y-m-d H:i:s")."\n";
         $project = $projects[rand(0, count($projects) - 1)];
         $author = $authors[rand(0, count($authors) - 1)];
         $path = $path_root . $project;
         $subject = "[GIT] bare, branch master updated: Test commit";
         $content = "\nThe project \"{$project}\":\n\nThe branch, master has been updated\nvia  70a503a72a0843b4a699ea7d0ad37cd27486a20e (commit)\nfrom  d1e5490d9177cb6420e25c5f9d37b9353b845fdf (commit)\n\n\n- Log -----------------------------------------------------------------\ncommit 70a503a72a0843b4a699ea7d0ad37cd27486a20e\nAuthor: {$author}\nDate:   Wed Jan 13 22:26:33 2016 +0100\n\nTest commit\n\n-----------------------------------------------------------------------\n\nSummary of changes:\nfile.txt | 1 +\n1 file changed, 1 insertion(+)\n\n--\n{$project}";
         $push = new Push();
         $push->setPath($path);
         $push->setSubject($subject);
         $push->setProject($project);
         $push->setText(trim($content));
         $push->setDatetime($datetime);
         $manager->persist($push);
     }
     foreach ($authors as $author) {
         $a = new Author($author);
         $manager->persist($a);
     }
     $manager->flush();
 }