@@ -393,16 +393,18 @@ public function getDisplayNames($search = "", $limit = null, $offset = null)
393393 ["app " => $ this ->appName ]
394394 );
395395
396- if (empty ($ this ->properties [DB ::USER_NAME_COLUMN ])) {
397- return false ;
396+ $ users = $ this ->getUsers (
397+ $ search , $ limit , $ offset , function ($ user ) {
398+ return $ user ;
398399 }
399-
400- $ users = $ this ->getUsers ($ search , $ limit , $ offset );
400+ );
401401
402402 $ names = [];
403403 foreach ($ users as $ user ) {
404- if (!is_null ($ user ->name )) {
405- $ names [$ user ] = $ user ->name ;
404+ if (is_null ($ user ->name )) {
405+ $ names [$ user ->uid ] = $ user ->uid ;
406+ } else {
407+ $ names [$ user ->uid ] = $ user ->name ;
406408 }
407409 }
408410
@@ -417,10 +419,11 @@ public function getDisplayNames($search = "", $limit = null, $offset = null)
417419 /**
418420 * @inheritdoc
419421 */
420- public function getUsers ($ search = "" , $ limit = null , $ offset = null )
421- {
422+ public function getUsers (
423+ $ search = "" , $ limit = null , $ offset = null , $ callback = null
424+ ) {
422425 $ this ->logger ->debug (
423- "Entering getUsers( $ search, $ limit, $ offset) " ,
426+ "Entering getUsers( $ search, $ limit, $ offset, $ callback ) " ,
424427 ["app " => $ this ->appName ]
425428 );
426429
@@ -448,15 +451,17 @@ public function getUsers($search = "", $limit = null, $offset = null)
448451 $ this ->cache ->set ("user_ " . $ user ->uid , $ user );
449452 }
450453
451- $ users = array_map (
452- function ($ user ) {
454+ $ callback = is_callable ($ callback )
455+ ? $ callback
456+ : function ($ user ) {
453457 return $ user ->uid ;
454- }, $ users
455- );
458+ };
459+ $ users = array_map ( $ callback , $ users );
456460
457461 $ this ->cache ->set ($ cacheKey , $ users );
458462 $ this ->logger ->debug (
459- "Returning getUsers( $ search, $ limit, $ offset): count( " . count (
463+ "Returning getUsers( $ search, $ limit, $ offset, $ callback): count( "
464+ . count (
460465 $ users
461466 ) . ") " , ["app " => $ this ->appName ]
462467 );
0 commit comments