2222
2323abstract class BasePresentationAuditLogFormatter extends AbstractAuditLogFormatter
2424{
25- protected string $ event_type ;
26-
2725 public function __construct (string $ event_type )
2826 {
29- $ this ->event_type = $ event_type ;
30- }
31-
32- protected function extractChangedFields (array $ change_set ): array
33- {
34- $ changed_fields = [];
35- $ old_status = null ;
36- $ new_status = null ;
37-
38- if (isset ($ change_set ['Title ' ])) {
39- $ changed_fields [] = "title " ;
40- }
41- if (isset ($ change_set ['Abstract ' ])) {
42- $ changed_fields [] = "abstract " ;
43- }
44- if (isset ($ change_set ['ProblemAddressed ' ])) {
45- $ changed_fields [] = "problem_addressed " ;
46- }
47- if (isset ($ change_set ['AttendeesExpectedLearnt ' ])) {
48- $ changed_fields [] = "attendees_expected_learnt " ;
49- }
50-
51- if (isset ($ change_set ['Status ' ])) {
52- $ changed_fields [] = "status " ;
53- $ old_status = $ change_set ['Status ' ][0 ] ?? null ;
54- $ new_status = $ change_set ['Status ' ][1 ] ?? null ;
55- }
56- if (isset ($ change_set ['CategoryID ' ]) || isset ($ change_set ['category ' ])) {
57- $ changed_fields [] = "track " ;
58- }
59- if (isset ($ change_set ['Published ' ])) {
60- $ changed_fields [] = "published " ;
61- }
62- if (isset ($ change_set ['SelectionPlanID ' ])) {
63- $ changed_fields [] = "selection_plan " ;
64- }
65-
66- return [
67- 'fields ' => !empty ($ changed_fields ) ? implode (', ' , $ changed_fields ) : 'properties ' ,
68- 'old_status ' => $ old_status ,
69- 'new_status ' => $ new_status ,
70- ];
27+ parent ::__construct ($ event_type );
7128 }
7229
7330 protected function getPresentationData (Presentation $ subject ): array
@@ -91,7 +48,7 @@ protected function getPresentationData(Presentation $subject): array
9148 ];
9249 }
9350
94- public function format ($ subject , array $ change_set ): ?string
51+ public function format (mixed $ subject , array $ change_set ): ?string
9552 {
9653 if (!$ subject instanceof Presentation) {
9754 return null ;
@@ -105,9 +62,7 @@ public function format($subject, array $change_set): ?string
10562 return $ this ->formatCreation ($ data );
10663
10764 case IAuditStrategy::EVENT_ENTITY_UPDATE :
108- $ extracted = $ this ->extractChangedFields ($ change_set );
109- $ extracted ['change_set ' ] = $ change_set ;
110- return $ this ->formatUpdate ($ data , $ extracted );
65+ return $ this ->formatUpdate ($ data , $ change_set );
11166
11267 case IAuditStrategy::EVENT_ENTITY_DELETION :
11368 return $ this ->formatDeletion ($ data );
@@ -121,7 +76,7 @@ public function format($subject, array $change_set): ?string
12176
12277 abstract protected function formatCreation (array $ data ): string ;
12378
124- abstract protected function formatUpdate (array $ data , array $ extracted ): string ;
79+ abstract protected function formatUpdate (array $ data , array $ change_set ): string ;
12580
12681 abstract protected function formatDeletion (array $ data ): string ;
12782}
0 commit comments