예제 #1
0
 /**
  * @inheritDoc
  */
 public function process(array $projects, $options = array())
 {
     if (empty($projects)) {
         return array();
     }
     $reports = array();
     $release_history = new ReleaseHistory();
     /** @var Project $project */
     foreach ($projects as $project) {
         $release_history->prepare($project);
         $event = new CerbereDoActionEvent($this, $project);
         $this->getDispatcher()->dispatch(CerbereEvents::CERBERE_DO_ACTION, $event);
         if ($filename = $project->getFilename()) {
             $current_dir = getcwd();
             // Change current directory to the module directory.
             chdir($project->getWorkingDirectory());
             $hacked = new HackedProject($project);
             $result = $hacked->computeReport();
             $report = array('project' => $project->getProject(), 'type' => $project->getProjectType(), 'version' => $project->getVersion(), 'version_date' => $project->getDatestamp(), 'status' => $result['status'], 'status_label' => HackedProject::getStatusLabel($result['status']), 'modified' => $result['counts']['different'], 'deleted' => $result['counts']['missing']);
             $event = new CerbereReportActionEvent($this, $project, $report);
             $this->getDispatcher()->dispatch(CerbereEvents::CERBERE_REPORT_ACTION, $event);
             $report = $event->getReport();
             $reports[] = $report;
             // Restore current directory.
             chdir($current_dir);
         }
         $event = new CerbereDoneActionEvent($this, $project);
         $this->getDispatcher()->dispatch(CerbereEvents::CERBERE_DONE_ACTION, $event);
     }
     return $reports;
 }
예제 #2
0
 /**
  * @param Project[] $projects
  * @param array $options
  *
  * @return array
  */
 public function process(array $projects, $options = array())
 {
     $options += array('cache' => true, 'level' => 'all', 'flat' => false);
     $reports = array();
     $release_history = new ReleaseHistory($this->cache);
     /** @var Project $project */
     foreach ($projects as $project) {
         $event = new CerbereDoActionEvent($this, $project);
         $this->getDispatcher()->dispatch(CerbereEvents::CERBERE_DO_ACTION, $event);
         $release_history->prepare($project, $options['cache']);
         $release_history->compare($project);
         switch ($options['level']) {
             case 'security':
                 $level = ReleaseHistory::UPDATE_NOT_SECURE;
                 break;
             case 'unsupported':
                 $level = ReleaseHistory::UPDATE_NOT_SUPPORTED;
                 break;
             case 'update':
                 $level = ReleaseHistory::UPDATE_NOT_CURRENT;
                 break;
             default:
                 $level = ReleaseHistory::UPDATE_CURRENT;
         }
         if ($project->getStatus() <= $level) {
             $report = $this->generateReport($project, $release_history, $options['flat']);
             $event = new CerbereReportActionEvent($this, $project, $report, $options);
             $this->getDispatcher()->dispatch(CerbereEvents::CERBERE_REPORT_ACTION, $event);
             $report = $event->getReport();
             $reports[$project->getProject()] = $report;
         }
         $event = new CerbereDoneActionEvent($this, $project);
         $this->getDispatcher()->dispatch(CerbereEvents::CERBERE_DONE_ACTION, $event);
     }
     return $reports;
 }