/** * Checks a configuration. * * @see paAlert */ public function getAlertOutput(paAlert $alert) { $pluginAssetsPath = $this->config['plugin']['assets_path']; switch ($alert->getStatus()) { case paAlert::ALERT: case paAlert::CRIT: case paAlert::ERR: $color = '#fd3900'; $image = $pluginAssetsPath . '/images/alert.png'; $alt = 'fatal'; break; case paAlert::WARNING: $color = '#6a9ee6'; $image = $pluginAssetsPath . '/images/warning.png'; $alt = 'warning'; break; case paAlert::NOTICE: case paAlert::INFO: $color = '#60b111'; $image = $pluginAssetsPath . '/images/check.png'; $alt = 'ok'; break; default: throw new RuntimeException(sprintf('The "%d" alert status is not handled ! It must be implemented in the sfProjectAnalyseTask::getAlertOutput() function.', $alert->getStatus()), -1); break; } return sprintf(' <div style="background-color: %s; padding: 4px; margin: 3px; border: 1px #ddd solid; font-size: 18px"> <div style="float: left"><img alt="%s" style="width: 60%%; vertical-align: middle; margin-right: 10px" src="%s" /></div> <div style="float: left; margin-top: 7px; text-align: left;">%s%s</div> <div style="clear: both"></div> </div>', $color, $alt, $image, $alert->getMessage(), $alert->hasHelp() ? '<div style="background-color: #fff; padding:5px">What to do: ' . $alert->getHelp() . '</div>' : ''); }
/** * Check and process the alerts specific to the project. */ protected function processFinalAlert() { // Add the alert summary if ($this->hasAlerts()) { $html = ''; $countAlerts = $this->countAlerts(); $maxAlertStatus = paAlert::INFO; foreach ($this->getAlertsSummary() as $status => $count) { if ($count > 0) { if ($status < $maxAlertStatus) { $maxAlertStatus = $status; } $html .= sprintf(' » %d %s(S)<br/>', $count, paAlert::getStatusLabel($status)); } } $alert = new paAlert(paAlert::ALERT_PROJECT_ANALYSIS_NOK, $maxAlertStatus, sprintf('The project has "%d" alert(s) according to the coding standards of the "%s" configuration:<br/>' . $html, $countAlerts, $this->getConfigName())); } else { $alert = new paAlert(paAlert::ALERT_PROJECT_ANALYSIS_OK, paAlert::INFO, sprintf('Congratulations ! The project "%s" respects the symfony coding standards of the "%s" configuration.', $this->getName(), $this->getConfigName())); } $this->addAlert($alert); }