From 828304d983531c915ddeabe70a8fb0149c1d829e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 4 Apr 2024 22:12:49 +0200 Subject: [PATCH] Replace getUsername with getUserIdentifier in activity checks Updated activity checks in ListActivitiesByAccompanyingPeriodContext to use getUserIdentifier method instead of getUsername. This change corresponds to check for both activity users and work referrers. The getUserIdentifier method grants a more reliable way to identify users. --- .../ListActivitiesByAccompanyingPeriodContext.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php index 9298983c2..a2fa996a6 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php @@ -122,13 +122,13 @@ class ListActivitiesByAccompanyingPeriodContext implements function ($activity) use ($user) { $u = $activity['user']; - if (null !== $u && $u['username'] === $user->getUsername()) { + if (null !== $u && $u['username'] === $user->getUserIdentifier()) { return true; } $activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []); - return \in_array($user->getUsername(), $activityUsernames, true); + return \in_array($user->getUserIdentifier(), $activityUsernames, true); } ) ); @@ -143,9 +143,9 @@ class ListActivitiesByAccompanyingPeriodContext implements array_filter( $works, function ($work) use ($user) { - $workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []); + $workUsernames = array_map(static fn (User $user) => $user['username'], $work['referrers'] ?? []); - return \in_array($user->getUsername(), $workUsernames, true); + return \in_array($user->getUserIdentifier(), $workUsernames, true); } ) );