$entry->getProperty('UID'), $entries) ); $statuses = $this->statusService->findByUserIds($uids); /** @var array $indexed */ $indexed = array_combine( array_map(fn (UserStatus $status) => $status->getUserId(), $statuses), $statuses ); foreach ($entries as $entry) { $uid = $entry->getProperty('UID'); if ($uid !== null && isset($indexed[$uid])) { $status = $indexed[$uid]; $entry->setStatus( $status->getStatus(), $status->getCustomMessage(), $status->getStatusMessageTimestamp(), $status->getCustomIcon(), ); } } } }