mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-14 09:57:43 +00:00
Refactor subject conversion in AuditEvent2Trail and enhance SubjectConverterInterface
- Replaced `array_map` with `array_reduce` in `AuditEvent2Trail` for flattening converted subjects. - Enhanced `SubjectConverterInterface` with a `supportsConvert` method and PHPStan annotations to improve type safety and flexibility.
This commit is contained in:
@@ -34,7 +34,13 @@ final readonly class AuditEvent2Trail implements AuditEvent2TrailInterface
|
||||
$event->description->trans($this->translator)
|
||||
: $event->description;
|
||||
|
||||
$targets = array_map(fn (mixed $subject) => $this->subjectConverterManager->convertEntityToSubjects($subject), $event->subjects);
|
||||
$targets = array_reduce(
|
||||
$event->subjects,
|
||||
function (array $carry, mixed $item): array {
|
||||
return array_merge($carry, $this->subjectConverterManager->convertEntityToSubjects($item));
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
$user = $this->security->getUser();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user