Conditions | 2 |
Paths | 2 |
Total Lines | 20 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
17 | public function onKernelException(ExceptionEvent $event) |
||
18 | { |
||
19 | $slack_webhook = $this->paramter->get('ribs_admin.slack_webhook'); |
||
20 | if ($slack_webhook) { |
||
21 | $data = array(); |
||
22 | $data['channel'] = '#errors'; |
||
23 | $data['username'] = $_SERVER['HTTP_HOST']; |
||
24 | $data['text'] = "• *Erreur* : " . strip_tags($event->getThrowable()->getMessage()); |
||
25 | $data['text'] .= "\n• *Erreur File* : " . strip_tags($event->getThrowable()->getFile()) . " at line :" . strip_tags($event->getThrowable()->getLine()); |
||
26 | $data['unfurl_links'] = false; |
||
27 | $data_json = json_encode($data); |
||
28 | |||
29 | $ch = curl_init(); |
||
30 | curl_setopt($ch, CURLOPT_URL, $slack_webhook); |
||
|
|||
31 | curl_setopt($ch, CURLOPT_POST, 1); |
||
32 | curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json))); |
||
33 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json); |
||
34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||
35 | curl_exec($ch); |
||
36 | curl_close($ch); |
||
37 | } |
||
39 | } |