This commit is contained in:
Dmitry 2016-10-25 14:43:21 +00:00 committed by GitHub
commit 88bdb2dd59

View file

@ -126,13 +126,21 @@ class BuildStatusController extends \PHPCI\Controller
}
/**
* Returns the appropriate build status image in SVG format for a given project.
*/
* Returns the appropriate build status image in SVG format for a given project.
*/
public function image($projectId)
{
// plastic|flat|flat-squared|social
$style = $this->getParam('style', 'plastic');
$label = $this->getParam('label', 'build');
$optionalParams = [
'logo' => $this->getParam('logo'),
'logoWidth' => $this->getParam('logoWidth'),
'link' => $this->getParam('link'),
'maxAge' => $this->getParam('maxAge'),
];
$status = $this->getStatus($projectId);
if (is_null($status)) {
@ -150,9 +158,16 @@ class BuildStatusController extends \PHPCI\Controller
$style
));
foreach ($optionalParams as $paramName => $param) {
if ($param) {
$image .= '&' . $paramName . '=' . $param;
}
}
$this->response->disableLayout();
$this->response->setHeader('Content-Type', 'image/svg+xml');
$this->response->setContent($image);
return $this->response;
}