Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

Commit 546a8c1

Browse files
committed
Make sure email annotation is only set when actually available in LDAP resource
1 parent 4889b05 commit 546a8c1

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/AppBundle/Ldap/Normalizer.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ public function denormalizeUsers(array $users)
2121
for ($i = 0; $i < $users['count']; $i++) {
2222
$user = $users[$i];
2323

24+
$annotations = [];
25+
26+
if (isset($user['mail'][0])) {
27+
$annotations['email'] = $user['mail'][0];
28+
}
29+
2430
$result[] = new User(
2531
null,
2632
$user['dn'],
2733
$user['givenname'][0],
2834
$user['sn'][0],
2935
$user['uid'][0],
30-
[
31-
'email' => isset($user['mail'][0]) ? $user['mail'][0] : ''
32-
]
36+
$annotations
3337
);
3438
}
3539

0 commit comments

Comments
 (0)