Improved build status image (Added optional params for shield.io)
This commit is contained in:
parent
64b0f60368
commit
bcc73ef4f8
|
@ -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)
|
public function image($projectId)
|
||||||
{
|
{
|
||||||
|
// plastic|flat|flat-squared|social
|
||||||
$style = $this->getParam('style', 'plastic');
|
$style = $this->getParam('style', 'plastic');
|
||||||
$label = $this->getParam('label', 'build');
|
$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);
|
$status = $this->getStatus($projectId);
|
||||||
|
|
||||||
if (is_null($status)) {
|
if (is_null($status)) {
|
||||||
|
@ -150,9 +158,16 @@ class BuildStatusController extends \PHPCI\Controller
|
||||||
$style
|
$style
|
||||||
));
|
));
|
||||||
|
|
||||||
|
foreach ($optionalParams as $paramName => $param) {
|
||||||
|
if ($param) {
|
||||||
|
$image .= '&' . $paramName . '=' . $param;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->response->disableLayout();
|
$this->response->disableLayout();
|
||||||
$this->response->setHeader('Content-Type', 'image/svg+xml');
|
$this->response->setHeader('Content-Type', 'image/svg+xml');
|
||||||
$this->response->setContent($image);
|
$this->response->setContent($image);
|
||||||
|
|
||||||
return $this->response;
|
return $this->response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue