Skip to content

Commit b38674a

Browse files
author
Gertjan Roke
authored
Added a fallback on the getKey method
1 parent 44c0d2d commit b38674a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/MonologHandler.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@ protected function addContext(array $context = [])
4242
$data = @call_user_func($config['person_fn']);
4343
if (! empty($data)) {
4444
if (is_object($data)) {
45-
if (method_exists($data, 'getKey')) {
45+
if (isset($data->id)) {
46+
$person['id'] = $data->id;
47+
} elseif (method_exists($data, 'getKey')) {
4648
$person['id'] = $data->getKey();
49+
}
50+
51+
if (isset($person['id'])) {
4752
if (isset($data->username)) {
4853
$person['username'] = $data->username;
4954
}

0 commit comments

Comments
 (0)