Skip to content

Commit 51584e0

Browse files
feat: add new formatters for attendees and add audit_log config for doctrine event listener (#481)
1 parent 3d4bcdb commit 51584e0

9 files changed

Lines changed: 451 additions & 0 deletions
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace App\Audit\ConcreteFormatters;
4+
5+
/**
6+
* Copyright 2026 OpenStack Foundation
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
use App\Audit\AbstractAuditLogFormatter;
19+
use App\Audit\Interfaces\IAuditStrategy;
20+
use models\main\Affiliation;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class AffiliationAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof Affiliation) {
28+
return null;
29+
}
30+
31+
try {
32+
$id = $subject->getId() ?? 'unknown';
33+
$owner = $subject->getOwner();
34+
$owner_name = $owner ? trim(($owner->getFirstName() ?? '') . ' ' . ($owner->getLastName() ?? '')) : 'Unknown Owner';
35+
$job_title = $subject->getJobTitle() ?? 'Unknown Job Title';
36+
37+
switch ($this->event_type) {
38+
case IAuditStrategy::EVENT_ENTITY_CREATION:
39+
return sprintf("Affiliation (%s) for '%s' (%s) created by user %s", $id, $owner_name, $job_title, $this->getUserInfo());
40+
41+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
42+
$details = $this->buildChangeDetails($change_set);
43+
return sprintf("Affiliation (%s) for '%s' (%s) updated: %s by user %s", $id, $owner_name, $job_title, $details, $this->getUserInfo());
44+
45+
case IAuditStrategy::EVENT_ENTITY_DELETION:
46+
return sprintf("Affiliation (%s) for '%s' (%s) deleted by user %s", $id, $owner_name, $job_title, $this->getUserInfo());
47+
}
48+
} catch (\Exception $ex) {
49+
Log::warning("AffiliationAuditLogFormatter error: " . $ex->getMessage());
50+
}
51+
52+
return null;
53+
}
54+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace App\Audit\ConcreteFormatters;
4+
5+
/**
6+
* Copyright 2026 OpenStack Foundation
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
use App\Audit\AbstractAuditLogFormatter;
19+
use App\Audit\Interfaces\IAuditStrategy;
20+
use models\summit\PresentationAttendeeVote;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class PresentationAttendeeVoteAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof PresentationAttendeeVote) {
28+
return null;
29+
}
30+
31+
try {
32+
$id = $subject->getId() ?? 'unknown';
33+
$presentation = $subject->getPresentation();
34+
$title = $presentation ? ($presentation->getTitle() ?? 'Unknown Presentation') : 'Unknown Presentation';
35+
36+
switch ($this->event_type) {
37+
case IAuditStrategy::EVENT_ENTITY_CREATION:
38+
return sprintf("Presentation Attendee Vote (%s) for '%s' created by user %s", $id, $title, $this->getUserInfo());
39+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
40+
$details = $this->buildChangeDetails($change_set);
41+
return sprintf("Presentation Attendee Vote (%s) for '%s' updated: %s by user %s", $id, $title, $details, $this->getUserInfo());
42+
case IAuditStrategy::EVENT_ENTITY_DELETION:
43+
return sprintf("Presentation Attendee Vote (%s) for '%s' deleted by user %s", $id, $title, $this->getUserInfo());
44+
}
45+
} catch (\Exception $ex) {
46+
Log::warning("PresentationAttendeeVoteAuditLogFormatter error: " . $ex->getMessage());
47+
}
48+
49+
return null;
50+
}
51+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace App\Audit\ConcreteFormatters;
4+
5+
/**
6+
* Copyright 2026 OpenStack Foundation
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
use App\Audit\AbstractAuditLogFormatter;
19+
use App\Audit\Interfaces\IAuditStrategy;
20+
use models\summit\SummitAttendee;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitAttendeeAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitAttendee) {
28+
return null;
29+
}
30+
31+
try {
32+
$id = $subject->getId() ?? 'unknown';
33+
$name = trim(($subject->getFirstName() ?? '') . ' ' . ($subject->getSurname() ?? '')) ?: 'Unknown Attendee';
34+
35+
switch ($this->event_type) {
36+
case IAuditStrategy::EVENT_ENTITY_CREATION:
37+
return sprintf("Attendee (%s) '%s' created by user %s", $id, $name, $this->getUserInfo());
38+
39+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
40+
$details = $this->buildChangeDetails($change_set);
41+
return sprintf("Attendee (%s) '%s' updated: %s by user %s", $id, $name, $details, $this->getUserInfo());
42+
43+
case IAuditStrategy::EVENT_ENTITY_DELETION:
44+
return sprintf("Attendee (%s) '%s' deleted by user %s", $id, $name, $this->getUserInfo());
45+
}
46+
} catch (\Exception $ex) {
47+
Log::warning("SummitAttendeeAuditLogFormatter error: " . $ex->getMessage());
48+
}
49+
50+
return null;
51+
}
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace App\Audit\ConcreteFormatters;
4+
5+
/**
6+
* Copyright 2026 OpenStack Foundation
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
use App\Audit\AbstractAuditLogFormatter;
19+
use App\Audit\Interfaces\IAuditStrategy;
20+
use models\summit\SummitAttendeeBadge;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitAttendeeBadgeAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitAttendeeBadge) {
28+
return null;
29+
}
30+
31+
try {
32+
$id = $subject->getId() ?? 'unknown';
33+
$ticket = $subject->getTicket();
34+
$owner = $ticket ? $ticket->getOwner() : null;
35+
$owner_name = $owner ? trim(($owner->getFirstName() ?? '') . ' ' . ($owner->getSurname() ?? '')) : 'Unknown Owner';
36+
37+
switch ($this->event_type) {
38+
case IAuditStrategy::EVENT_ENTITY_CREATION:
39+
return sprintf("Attendee Badge (%s) for '%s' created by user %s", $id, $owner_name, $this->getUserInfo());
40+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
41+
$details = $this->buildChangeDetails($change_set);
42+
return sprintf("Attendee Badge (%s) for '%s' updated: %s by user %s", $id, $owner_name, $details, $this->getUserInfo());
43+
case IAuditStrategy::EVENT_ENTITY_DELETION:
44+
return sprintf("Attendee Badge (%s) for '%s' deleted by user %s", $id, $owner_name, $this->getUserInfo());
45+
}
46+
} catch (\Exception $ex) {
47+
Log::warning("SummitAttendeeBadgeAuditLogFormatter error: " . $ex->getMessage());
48+
}
49+
50+
return null;
51+
}
52+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace App\Audit\ConcreteFormatters;
4+
5+
/**
6+
* Copyright 2026 OpenStack Foundation
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
use App\Audit\AbstractAuditLogFormatter;
19+
use App\Audit\Interfaces\IAuditStrategy;
20+
use models\summit\SummitAttendeeNote;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitAttendeeNoteAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitAttendeeNote) {
28+
return null;
29+
}
30+
31+
try {
32+
$id = $subject->getId() ?? 'unknown';
33+
$owner = $subject->getOwner();
34+
$owner_name = $owner ? trim(($owner->getFirstName() ?? '') . ' ' . ($owner->getSurname() ?? '')) : 'Unknown Owner';
35+
36+
switch ($this->event_type) {
37+
case IAuditStrategy::EVENT_ENTITY_CREATION:
38+
return sprintf("Attendee Note (%s) for '%s' created by user %s", $id, $owner_name, $this->getUserInfo());
39+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
40+
$details = $this->buildChangeDetails($change_set);
41+
return sprintf("Attendee Note (%s) for '%s' updated: %s by user %s", $id, $owner_name, $details, $this->getUserInfo());
42+
case IAuditStrategy::EVENT_ENTITY_DELETION:
43+
return sprintf("Attendee Note (%s) for '%s' deleted by user %s", $id, $owner_name, $this->getUserInfo());
44+
}
45+
} catch (\Exception $ex) {
46+
Log::warning("SummitAttendeeNoteAuditLogFormatter error: " . $ex->getMessage());
47+
}
48+
49+
return null;
50+
}
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace App\Audit\ConcreteFormatters;
4+
5+
/**
6+
* Copyright 2026 OpenStack Foundation
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
use App\Audit\AbstractAuditLogFormatter;
19+
use App\Audit\Interfaces\IAuditStrategy;
20+
use models\summit\SummitAttendeeTicket;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitAttendeeTicketAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitAttendeeTicket) {
28+
return null;
29+
}
30+
31+
try {
32+
$id = $subject->getId() ?? 'unknown';
33+
$owner = $subject->getOwner();
34+
$owner_name = $owner ? trim(($owner->getFirstName() ?? '') . ' ' . ($owner->getSurname() ?? '')) : 'Unknown Owner';
35+
36+
switch ($this->event_type) {
37+
case IAuditStrategy::EVENT_ENTITY_CREATION:
38+
return sprintf("Attendee Ticket (%s) for '%s' created by user %s", $id, $owner_name, $this->getUserInfo());
39+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
40+
$details = $this->buildChangeDetails($change_set);
41+
return sprintf("Attendee Ticket (%s) for '%s' updated: %s by user %s", $id, $owner_name, $details, $this->getUserInfo());
42+
case IAuditStrategy::EVENT_ENTITY_DELETION:
43+
return sprintf("Attendee Ticket (%s) for '%s' deleted by user %s", $id, $owner_name, $this->getUserInfo());
44+
}
45+
} catch (\Exception $ex) {
46+
Log::warning("SummitAttendeeTicketAuditLogFormatter error: " . $ex->getMessage());
47+
}
48+
49+
return null;
50+
}
51+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace App\Audit\ConcreteFormatters;
4+
5+
/**
6+
* Copyright 2026 OpenStack Foundation
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
use App\Audit\AbstractAuditLogFormatter;
19+
use App\Audit\Interfaces\IAuditStrategy;
20+
use models\summit\SummitAttendeeTicketTax;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitAttendeeTicketTaxAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitAttendeeTicketTax) {
28+
return null;
29+
}
30+
31+
try {
32+
$id = $subject->getId() ?? 'unknown';
33+
$tax = $subject->getTax();
34+
$tax_name = $tax ? ($tax->getName() ?? 'Unknown Tax') : 'Unknown Tax';
35+
$ticket = $subject->getTicket();
36+
$ticket_id = $ticket ? $ticket->getId() : 'unknown';
37+
38+
switch ($this->event_type) {
39+
case IAuditStrategy::EVENT_ENTITY_CREATION:
40+
return sprintf("Attendee Ticket Tax (%s) '%s' for ticket %s created by user %s", $id, $tax_name, $ticket_id, $this->getUserInfo());
41+
42+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
43+
$details = $this->buildChangeDetails($change_set);
44+
return sprintf("Attendee Ticket Tax (%s) '%s' for ticket %s updated: %s by user %s", $id, $tax_name, $ticket_id, $details, $this->getUserInfo());
45+
46+
case IAuditStrategy::EVENT_ENTITY_DELETION:
47+
return sprintf("Attendee Ticket Tax (%s) '%s' for ticket %s deleted by user %s", $id, $tax_name, $ticket_id, $this->getUserInfo());
48+
}
49+
} catch (\Exception $ex) {
50+
Log::warning("SummitAttendeeTicketTaxAuditLogFormatter error: " . $ex->getMessage());
51+
}
52+
53+
return null;
54+
}
55+
}

0 commit comments

Comments
 (0)