コード例 #1
0
 /**
  * Sends a message to slack created by information given in the event.
  *
  * @param Event $event
  */
 public function send(Event $event)
 {
     $client = new \Maknz\Slack\Client($this->webhookURL, $this->settings);
     $gotoUrl = "<" . $this->router->generate("bauer_incident_dashboard_core_homepage", array('project' => $event->getEventIdentifier()->getProject()->getIdentifier()), true) . "|Go to www.koalamon.com>";
     if ($event->hasUrl()) {
         $gotoUrl .= "\n<" . $event->getUrl() . "|Go to " . $event->getEventIdentifier()->getTool()->getName() . ">";
     }
     if ($event->getStatus() == Event::STATUS_SUCCESS) {
         $color = self::COLOR_SUCCESS;
         $label = "Your test succeeded (" . $event->getSystem() . ")\nIdentifier: " . $event->getEventIdentifier()->getIdentifier() . ")";
         $message = "";
     } else {
         $color = self::COLOR_FAILURE;
         $label = "Your test failed (" . $event->getSystem() . ") \nIdentifier: " . $event->getEventIdentifier()->getIdentifier() . "";
         $message = $this->slackifyText($event->getMessage()) . "\n";
     }
     $client->enableMarkdown()->attach(['text' => $message . $gotoUrl, 'color' => $color])->send($label);
 }