/** * @param Job $job * @param array $options * * @return array */ public function run(Job $job, $options = array()) { // Download remote project if remote. $dir = $job->checkoutRepository(); // Move to project folder. $currentDirectory = getcwd(); chdir($dir); // Load projects from repository. $projects = $this->getProjectsFromPatterns($job->getPatterns(), $job->isPatternNested()); $projects = $this->dedupeProjectList($projects); $event = new CerberePreActionEvent($this, $job, $job->getAction(), $projects); $this->getDispatcher()->dispatch(CerbereEvents::CERBERE_PRE_ACTION, $event); // Do cerbere action. $job->getAction()->prepare(); $report = $job->getAction()->process($projects, $options); $event = new CerberePostActionEvent($this, $job, $job->getAction(), $projects); $this->getDispatcher()->dispatch(CerbereEvents::CERBERE_POST_ACTION, $event); // Restore initial directory. chdir($currentDirectory); return $report; }