/** * @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; }
/** * @param Project $project * @param ReleaseHistory $release_history * @param boolean $flat * @return array */ protected function generateReport(Project $project, ReleaseHistory $release_history, $flat = false) { $report = array('project' => $project->getProject(), 'type' => $project->getProjectType(), 'version' => $project->getVersion(), 'version_date' => $project->getDatestamp(), 'recommended' => null, 'dev' => null, 'also_available' => array(), 'status' => $project->getStatus(), 'status_label' => ReleaseHistory::getStatusLabel($project->getStatus()), 'reason' => ''); if ($flat) { $report['recommended'] = $project->getRecommended(); $report['dev'] = $project->getDevVersion(); $report['also_available'] = implode(',', $project->getAlsoAvailable()); } else { if ($release = $release_history->getRelease($project->getRecommended())) { $report['recommended'] = $this->getReportFromRelease($release); } if ($release = $release_history->getRelease($project->getDevVersion())) { $report['dev'] = $this->getReportFromRelease($release); } foreach ($project->getAlsoAvailable() as $version) { if ($release = $project->getRelease($version)) { $report['also_available'][] = $this->getReportFromRelease($release); } } } if ($reason = $project->getReason()) { $report['reason'] = $reason; } return $report; }