* @package PHPCI * @subpackage Web */ class BuildStatusController extends b8\Controller { public function init() { $this->_projectStore = Store\Factory::getStore('Project'); } /** * Returns the appropriate build status image for a given project. */ public function image($projectId) { $branch = $this->getParam('branch', 'master'); $project = $this->_projectStore->getById($projectId); $status = 'ok'; if (isset($project) && $project instanceof Project) { $build = $project->getLatestBuild($branch, array(2,3)); if (isset($build) && $build instanceof Build && $build->getStatus() != 2) { $status = 'failed'; } } header('Content-Type: image/png'); die(file_get_contents(APPLICATION_PATH . 'assets/img/build-' . $status . '.png')); } }