Skip to content

Commit cf5fd28

Browse files
Revert "feat : Add PresentationTrackChairFormatter (#464)"
This reverts commit eb3a048.
1 parent eb4fd7e commit cf5fd28

6 files changed

Lines changed: 23 additions & 342 deletions

app/Audit/AuditLogFormatterFactory.php

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ public function __construct()
2929
$this->config = config('audit_log', []);
3030
}
3131

32+
public function getStrategyClass(object $subject, string $event_type): ?IAuditLogFormatter
33+
{
34+
$class = get_class($subject);
35+
$cls = $this->config['entities'][$class]['strategy'] ?? null;
36+
return !is_null($cls) ? new $cls($event_type):null;
37+
}
38+
3239
public function make(AuditContext $ctx, $subject, $eventType): ?IAuditLogFormatter
3340
{
3441
$formatter = null;
@@ -46,19 +53,28 @@ public function make(AuditContext $ctx, $subject, $eventType): ?IAuditLogFormatt
4653
break;
4754
case IAuditStrategy::EVENT_ENTITY_CREATION:
4855
$formatter = $this->getFormatterByContext($subject, $eventType, $ctx);
56+
if (is_null($formatter)) {
57+
$formatter = $this->getStrategyClass($subject, $eventType);
58+
}
4959
if(is_null($formatter)) {
5060
$formatter = new EntityCreationAuditLogFormatter();
5161
}
5262
break;
5363
case IAuditStrategy::EVENT_ENTITY_DELETION:
5464
$formatter = $this->getFormatterByContext($subject, $eventType, $ctx);
65+
if (is_null($formatter)) {
66+
$formatter = $this->getStrategyClass($subject, $eventType);
67+
}
5568
if(is_null($formatter)) {
5669
$child_entity_formatter = ChildEntityFormatterFactory::build($subject);
5770
$formatter = new EntityDeletionAuditLogFormatter($child_entity_formatter);
5871
}
5972
break;
6073
case IAuditStrategy::EVENT_ENTITY_UPDATE:
6174
$formatter = $this->getFormatterByContext($subject, $eventType, $ctx);
75+
if (is_null($formatter)) {
76+
$formatter = $this->getStrategyClass($subject, $eventType);
77+
}
6278
if(is_null($formatter)) {
6379
$child_entity_formatter = ChildEntityFormatterFactory::build($subject);
6480
$formatter = new EntityUpdateAuditLogFormatter($child_entity_formatter);
@@ -74,24 +90,17 @@ private function getFormatterByContext(object $subject, string $event_type, Audi
7490
$class = get_class($subject);
7591
$entity_config = $this->config['entities'][$class] ?? null;
7692

77-
if (!$entity_config) {
93+
if (!$entity_config || !isset($entity_config['strategies'])) {
7894
return null;
7995
}
8096

81-
if (isset($entity_config['strategies'])) {
82-
foreach ($entity_config['strategies'] as $strategy) {
83-
if (!$this->matchesStrategy($strategy, $ctx)) {
84-
continue;
85-
}
86-
87-
$formatter_class = $strategy['formatter'] ?? null;
88-
return $formatter_class ? new $formatter_class($event_type) : null;
97+
foreach ($entity_config['strategies'] as $strategy) {
98+
if (!$this->matchesStrategy($strategy, $ctx)) {
99+
continue;
89100
}
90-
}
91101

92-
if (isset($entity_config['strategy'])) {
93-
$strategy_class = $entity_config['strategy'];
94-
return new $strategy_class($event_type);
102+
$formatter_class = $strategy['formatter'] ?? null;
103+
return $formatter_class ? new $formatter_class($event_type) : null;
95104
}
96105

97106
return null;

app/Audit/ConcreteFormatters/ChildEntityFormatters/PresentationTrackChairScoreAuditLogFormatter.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

app/Audit/ConcreteFormatters/PresentationTrackChairRatingTypeAuditLogFormatter.php

Lines changed: 0 additions & 80 deletions
This file was deleted.

app/Audit/ConcreteFormatters/PresentationTrackChairScoreTypeAuditLogFormatter.php

Lines changed: 0 additions & 85 deletions
This file was deleted.

app/Audit/ConcreteFormatters/SummitTrackChairAuditLogFormatter.php

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)