Refactor username mapping in activity context filter.

Replaced array_map with a foreach loop for clarity and maintainability when extracting usernames from work referrers. This ensures better readability and aligns with coding standards.
This commit is contained in:
Julien Fastré 2025-02-14 12:11:28 +01:00
parent ab35e8c034
commit 8db8f5fdf5
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,6 @@
kind: Fixed
body: fix generation of document with accompanying period context, and list of activities and works
time: 2025-02-14T12:10:10.920355454+01:00
custom:
Issue: ""
SchemaChange: No schema change

View File

@ -143,7 +143,10 @@ class ListActivitiesByAccompanyingPeriodContext implements
array_filter(
$works,
function ($work) use ($user) {
$workUsernames = array_map(static fn (User $user) => $user['username'], $work['referrers'] ?? []);
$workUsernames = [];
foreach ($work['referrers'] as $referrer) {
$workUsernames[] = $referrer['username'];
}
return \in_array($user->getUserIdentifier(), $workUsernames, true);
}