mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-08 14:16:42 +02: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:
@@ -31,6 +31,16 @@ class PushoverHandler extends SocketHandler
|
|||||||
private $highPriorityLevel;
|
private $highPriorityLevel;
|
||||||
private $emergencyLevel;
|
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
|
* Sounds the api supports by default
|
||||||
* @see https://pushover.net/api#sounds
|
* @see https://pushover.net/api#sounds
|
||||||
@@ -101,10 +111,16 @@ class PushoverHandler extends SocketHandler
|
|||||||
$dataArray['priority'] = 1;
|
$dataArray['priority'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($record['context']['sound']) && in_array($record['context']['sound'], $this->sounds)) {
|
// First determine the available parameters
|
||||||
$dataArray['sound'] = $record['context']['sound'];
|
$context = array_intersect_key($record['context'], array_flip($this->parameters));
|
||||||
} elseif (isset($record['extra']['sound']) && in_array($record['extra']['sound'], $this->sounds)) {
|
$extra = array_intersect_key($record['extra'], array_flip($this->parameters));
|
||||||
$dataArray['sound'] = $record['extra']['sound'];
|
|
||||||
|
// 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);
|
return http_build_query($dataArray);
|
||||||
|
Reference in New Issue
Block a user