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)) {
            $response = new b8\Http\Response\RedirectResponse();
            $response->setHeader('Location', '/');
            return $response;
        }

        $color = ($status == 'passing') ? 'green' : 'red';
        $image = file_get_contents(sprintf(
            'http://img.shields.io/badge/%s-%s-%s.svg?style=%s',
            $label,
            $status,
            $color,
            $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;
    }
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)) {
            $response = new b8\Http\Response\RedirectResponse();
            $response->setHeader('Location', '/');
            return $response;
        }

        $color = ($status == 'passing') ? 'green' : 'red';
        $image = file_get_contents(sprintf(
            'http://img.shields.io/badge/%s-%s-%s.svg?style=%s',
            $label,
            $status,
            $color,
            $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;
    }
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 ) ) { $ response = new b8 \ Http \ Response \ RedirectResponse ( ) ; $ response -> setHeader ( 'Location' , '/' ) ; return $ response ; } $ color = ( $ status == 'passing' ) ? 'green' : 'red' ; $ image = file_get_contents ( sprintf ( 'http://img.shields.io/badge/%s-%s-%s.svg?style=%s' , $ label , $ status , $ color , $ 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 ; }
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 .