/** * @expectedException lygav\slackbot\Exceptions\SlackRequestException */ public function testThrowExceptionOnEmptyRequest() { $bot = new SlackBot($this->url); $bot->send(); }
public function afterSave(Event $event, Employee $entity, ArrayObject $options) { if ($entity->created) { $name = $entity->first_name . ' ' . $entity->last_name; } //send message to Slack //add use statement at head of controller: use lygav\slackbot\SlackBot; //vendor code lygav php-slackbot, https://github.com/lygav/php-slackbot $bot = new SlackBot("https://hooks.slack.com/services/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"); //$bot->text("Hi")->send(); $attachment = $bot->buildAttachment("fallback text")->setPretext("New employee added:")->setText($name)->setColor("lightblue")->setAuthor("Olaf the Lofty")->setThumbUrl("http://carenta.somervillehouse.co.uk/img/employeeNew.png"); $bot->attach($attachment)->send(); }