mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-18 11:48:06 +00:00
Refactor subject conversion handling and enhance audit logging
- Replaced `Subject|array` return types with `SubjectBag` in `SubjectConverterInterface` for more robust handling. - Updated `getSubjectsForEntity` to include an optional `$includeAssociated` parameter for finer control over associated subject resolution. - Refactored `AuditEvent` to differentiate `mainSubject` from associated subjects, improving clarity in audit logging. - Introduced database schema changes to add `main_subject` and `subjects` columns in the `chill_main_audit_trail` table. - Added `SubjectBag` class for grouped subject management and implemented deduplication logic. - Updated all converters and test cases to use the new `SubjectBag` approach, ensuring compatibility. - Improved event dispatching in controllers to utilize the updated `AuditEvent` structure and refined metadata handling.
This commit is contained in:
@@ -22,7 +22,7 @@ final readonly class SubjectConverterManager implements SubjectConverterManagerI
|
||||
private iterable $converters,
|
||||
) {}
|
||||
|
||||
public function getSubjectsForEntity(mixed $subject): array
|
||||
public function getSubjectsForEntity(mixed $subject, bool $includeAssociated = false): SubjectBag
|
||||
{
|
||||
foreach ($this->converters as $converter) {
|
||||
if ($converter instanceof SubjectConverterManagerAwareInterface) {
|
||||
@@ -30,9 +30,7 @@ final readonly class SubjectConverterManager implements SubjectConverterManagerI
|
||||
}
|
||||
|
||||
if ($converter->supportsConvert($subject)) {
|
||||
$subjects = $converter->convert($subject);
|
||||
|
||||
return $subjects instanceof Subject ? [$subjects] : $subjects;
|
||||
return $converter->convert($subject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user