Skip to content

Commit 364e36a

Browse files
feat: add new formatters for Location and Rooms
1 parent 5fed732 commit 364e36a

13 files changed

+1235
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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\File;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class FileAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof File) {
28+
return null;
29+
}
30+
31+
try {
32+
$name = $subject->getName() ?? 'Unknown File';
33+
$id = $subject->getId() ?? 0;
34+
$filename = $subject->getFilename() ?? 'N/A';
35+
36+
switch ($this->event_type) {
37+
case IAuditStrategy::EVENT_ENTITY_CREATION:
38+
return sprintf(
39+
"File '%s' (%s) (%d) created by user %s",
40+
$name,
41+
$filename,
42+
$id,
43+
$this->getUserInfo()
44+
);
45+
46+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
47+
$change_details = $this->buildChangeDetails($change_set);
48+
return sprintf(
49+
"File '%s' (%s) (%d) updated: %s by user %s",
50+
$name,
51+
$filename,
52+
$id,
53+
$change_details,
54+
$this->getUserInfo()
55+
);
56+
57+
case IAuditStrategy::EVENT_ENTITY_DELETION:
58+
return sprintf(
59+
"File '%s' (%s) (%d) was deleted by user %s",
60+
$name,
61+
$filename,
62+
$id,
63+
$this->getUserInfo()
64+
);
65+
}
66+
} catch (\Exception $ex) {
67+
Log::warning("FileAuditLogFormatter error: " . $ex->getMessage());
68+
}
69+
70+
return null;
71+
}
72+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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 App\Models\Foundation\Summit\Locations\Banners\ScheduledSummitLocationBanner;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class ScheduledSummitLocationBannerAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof ScheduledSummitLocationBanner) {
28+
return null;
29+
}
30+
31+
try {
32+
$title = $subject->getTitle() ?? 'Unknown Banner';
33+
$id = $subject->getId() ?? 0;
34+
35+
$location = $subject->getLocation();
36+
$location_name = $location ? ($location->getName() ?? 'Unknown Location') : 'Unknown Location';
37+
38+
$summit = $location ? ($location->getSummit() ? ($location->getSummit()->getName() ?? 'Unknown Summit') : 'Unknown Summit') : 'Unknown Summit';
39+
40+
switch ($this->event_type) {
41+
case IAuditStrategy::EVENT_ENTITY_CREATION:
42+
return sprintf(
43+
"Scheduled Location Banner '%s' (%d) created for Location '%s' in Summit '%s' by user %s",
44+
$title,
45+
$id,
46+
$location_name,
47+
$summit,
48+
$this->getUserInfo()
49+
);
50+
51+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
52+
$change_details = $this->buildChangeDetails($change_set);
53+
return sprintf(
54+
"Scheduled Location Banner '%s' (%d) for Location '%s' in Summit '%s' updated: %s by user %s",
55+
$title,
56+
$id,
57+
$location_name,
58+
$summit,
59+
$change_details,
60+
$this->getUserInfo()
61+
);
62+
63+
case IAuditStrategy::EVENT_ENTITY_DELETION:
64+
return sprintf(
65+
"Scheduled Location Banner '%s' (%d) for Location '%s' in Summit '%s' was deleted by user %s",
66+
$title,
67+
$id,
68+
$location_name,
69+
$summit,
70+
$this->getUserInfo()
71+
);
72+
}
73+
} catch (\Exception $ex) {
74+
Log::warning("ScheduledSummitLocationBannerAuditLogFormatter error: " . $ex->getMessage());
75+
}
76+
77+
return null;
78+
}
79+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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\SummitBookableVenueRoom;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitBookableVenueRoomAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitBookableVenueRoom) {
28+
return null;
29+
}
30+
31+
try {
32+
$name = $subject->getName() ?? 'Unknown Room';
33+
$id = $subject->getId() ?? 0;
34+
35+
$venue = $subject->getVenue();
36+
$venue_name = $venue ? ($venue->getName() ?? 'Unknown Venue') : 'Unknown Venue';
37+
38+
$summit = $subject->getSummit();
39+
$summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit';
40+
41+
switch ($this->event_type) {
42+
case IAuditStrategy::EVENT_ENTITY_CREATION:
43+
return sprintf(
44+
"Bookable Venue Room '%s' (%d) created in Venue '%s' for Summit '%s' by user %s",
45+
$name,
46+
$id,
47+
$venue_name,
48+
$summit_name,
49+
$this->getUserInfo()
50+
);
51+
52+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
53+
$change_details = $this->buildChangeDetails($change_set);
54+
return sprintf(
55+
"Bookable Venue Room '%s' (%d) in Venue '%s' for Summit '%s' updated: %s by user %s",
56+
$name,
57+
$id,
58+
$venue_name,
59+
$summit_name,
60+
$change_details,
61+
$this->getUserInfo()
62+
);
63+
64+
case IAuditStrategy::EVENT_ENTITY_DELETION:
65+
return sprintf(
66+
"Bookable Venue Room '%s' (%d) in Venue '%s' for Summit '%s' was deleted by user %s",
67+
$name,
68+
$id,
69+
$venue_name,
70+
$summit_name,
71+
$this->getUserInfo()
72+
);
73+
}
74+
} catch (\Exception $ex) {
75+
Log::warning("SummitBookableVenueRoomAuditLogFormatter error: " . $ex->getMessage());
76+
}
77+
78+
return null;
79+
}
80+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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 App\Models\Foundation\Summit\Locations\Banners\SummitLocationBanner;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitLocationBannerAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitLocationBanner) {
28+
return null;
29+
}
30+
31+
try {
32+
$title = $subject->getTitle() ?? 'Unknown Banner';
33+
$id = $subject->getId() ?? 0;
34+
35+
$location = $subject->getLocation();
36+
$location_name = $location ? ($location->getName() ?? 'Unknown Location') : 'Unknown Location';
37+
38+
$summit = $location ? ($location->getSummit() ? ($location->getSummit()->getName() ?? 'Unknown Summit') : 'Unknown Summit') : 'Unknown Summit';
39+
40+
switch ($this->event_type) {
41+
case IAuditStrategy::EVENT_ENTITY_CREATION:
42+
return sprintf(
43+
"Location Banner '%s' (%d) created for Location '%s' in Summit '%s' by user %s",
44+
$title,
45+
$id,
46+
$location_name,
47+
$summit,
48+
$this->getUserInfo()
49+
);
50+
51+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
52+
$change_details = $this->buildChangeDetails($change_set);
53+
return sprintf(
54+
"Location Banner '%s' (%d) for Location '%s' in Summit '%s' updated: %s by user %s",
55+
$title,
56+
$id,
57+
$location_name,
58+
$summit,
59+
$change_details,
60+
$this->getUserInfo()
61+
);
62+
63+
case IAuditStrategy::EVENT_ENTITY_DELETION:
64+
return sprintf(
65+
"Location Banner '%s' (%d) for Location '%s' in Summit '%s' was deleted by user %s",
66+
$title,
67+
$id,
68+
$location_name,
69+
$summit,
70+
$this->getUserInfo()
71+
);
72+
}
73+
} catch (\Exception $ex) {
74+
Log::warning("SummitLocationBannerAuditLogFormatter error: " . $ex->getMessage());
75+
}
76+
77+
return null;
78+
}
79+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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\SummitLocationImage;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitLocationImageAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitLocationImage) {
28+
return null;
29+
}
30+
31+
try {
32+
$name = $subject->getName() ?? 'Unknown Image';
33+
$id = $subject->getId() ?? 0;
34+
35+
$location = $subject->getLocation();
36+
$location_name = $location ? ($location->getName() ?? 'Unknown Location') : 'Unknown Location';
37+
38+
$summit = $location ? ($location->getSummit() ? ($location->getSummit()->getName() ?? 'Unknown Summit') : 'Unknown Summit') : 'Unknown Summit';
39+
40+
switch ($this->event_type) {
41+
case IAuditStrategy::EVENT_ENTITY_CREATION:
42+
return sprintf(
43+
"Location Image '%s' (%d) created for Location '%s' in Summit '%s' by user %s",
44+
$name,
45+
$id,
46+
$location_name,
47+
$summit,
48+
$this->getUserInfo()
49+
);
50+
51+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
52+
$change_details = $this->buildChangeDetails($change_set);
53+
return sprintf(
54+
"Location Image '%s' (%d) for Location '%s' in Summit '%s' updated: %s by user %s",
55+
$name,
56+
$id,
57+
$location_name,
58+
$summit,
59+
$change_details,
60+
$this->getUserInfo()
61+
);
62+
63+
case IAuditStrategy::EVENT_ENTITY_DELETION:
64+
return sprintf(
65+
"Location Image '%s' (%d) for Location '%s' in Summit '%s' was deleted by user %s",
66+
$name,
67+
$id,
68+
$location_name,
69+
$summit,
70+
$this->getUserInfo()
71+
);
72+
}
73+
} catch (\Exception $ex) {
74+
Log::warning("SummitLocationImageAuditLogFormatter error: " . $ex->getMessage());
75+
}
76+
77+
return null;
78+
}
79+
}

0 commit comments

Comments
 (0)