mirror of
https://github.com/Seldaek/monolog.git
synced 2025-02-24 06:52:34 +01:00
Update PushoverHandler.php
... so all available parameters from the (API)[https://pushover.net/api] can be included in the record.
This commit is contained in:
parent
53c6cf358b
commit
8927351941
@ -31,6 +31,16 @@ class PushoverHandler extends SocketHandler
|
||||
private $highPriorityLevel;
|
||||
private $emergencyLevel;
|
||||
|
||||
/**
|
||||
* All parameters that can be sent to Pushover
|
||||
* @see https://pushover.net/api
|
||||
* @var array
|
||||
*/
|
||||
private $parameters = array(
|
||||
'token', 'user', 'message', // these are the required parameters
|
||||
'device', 'title', 'url', 'url_title', 'priority', 'timestamp', 'sound',
|
||||
);
|
||||
|
||||
/**
|
||||
* Sounds the api supports by default
|
||||
* @see https://pushover.net/api#sounds
|
||||
@ -101,10 +111,16 @@ class PushoverHandler extends SocketHandler
|
||||
$dataArray['priority'] = 1;
|
||||
}
|
||||
|
||||
if (isset($record['context']['sound']) && in_array($record['context']['sound'], $this->sounds)) {
|
||||
$dataArray['sound'] = $record['context']['sound'];
|
||||
} elseif (isset($record['extra']['sound']) && in_array($record['extra']['sound'], $this->sounds)) {
|
||||
$dataArray['sound'] = $record['extra']['sound'];
|
||||
// First determine the available parameters
|
||||
$context = array_intersect_key($record['context'], array_flip($this->parameters));
|
||||
$extra = array_intersect_key($record['extra'], array_flip($this->parameters));
|
||||
|
||||
// Least important info should be merged with latter
|
||||
$dataArray = array_merge($extra, $context, $dataArray);
|
||||
|
||||
// Get rid of sound in case it is not in the options
|
||||
if (isset($dataArray['sound']) && in_array($dataArray['sound'], $this->sounds) == false) {
|
||||
unset($dataArray['sound']);
|
||||
}
|
||||
|
||||
return http_build_query($dataArray);
|
||||
|
Loading…
x
Reference in New Issue
Block a user