From bcc73ef4f8aefed3b8fc044f560c5fd4b1a46d95 Mon Sep 17 00:00:00 2001 From: corpsee Date: Tue, 25 Oct 2016 21:40:13 +0700 Subject: [PATCH] Improved build status image (Added optional params for shield.io) --- PHPCI/Controller/BuildStatusController.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/PHPCI/Controller/BuildStatusController.php b/PHPCI/Controller/BuildStatusController.php index 62cb9ba7..033cc1e5 100644 --- a/PHPCI/Controller/BuildStatusController.php +++ b/PHPCI/Controller/BuildStatusController.php @@ -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; }