Skip to content

Commit 9fd08aa

Browse files
feat: add new formatters for signs and settings
1 parent 27c0e84 commit 9fd08aa

10 files changed

Lines changed: 905 additions & 0 deletions
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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\SummitDocument;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitDocumentAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitDocument) {
28+
return null;
29+
}
30+
31+
try {
32+
$name = $subject->getName() ?? 'Unknown Document';
33+
$id = $subject->getId() ?? 'unknown';
34+
$label = $subject->getLabel() ?? $name;
35+
$summit = $subject->getSummit();
36+
$summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit';
37+
38+
switch ($this->event_type) {
39+
case IAuditStrategy::EVENT_ENTITY_CREATION:
40+
return sprintf(
41+
"Summit Document '%s' (%d) created for Summit '%s' with label '%s' by user %s",
42+
$name,
43+
$id,
44+
$summit_name,
45+
$label,
46+
$this->getUserInfo()
47+
);
48+
49+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
50+
$change_details = $this->buildChangeDetails($change_set);
51+
return sprintf(
52+
"Summit Document '%s' (%d) for Summit '%s' updated: %s by user %s",
53+
$name,
54+
$id,
55+
$summit_name,
56+
$change_details,
57+
$this->getUserInfo()
58+
);
59+
60+
case IAuditStrategy::EVENT_ENTITY_DELETION:
61+
return sprintf(
62+
"Summit Document '%s' (%d) for Summit '%s' was deleted by user %s",
63+
$name,
64+
$id,
65+
$summit_name,
66+
$this->getUserInfo()
67+
);
68+
}
69+
} catch (\Exception $ex) {
70+
Log::warning("SummitDocumentAuditLogFormatter error: " . $ex->getMessage());
71+
}
72+
73+
return null;
74+
}
75+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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\SummitScheduleConfig;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitScheduleConfigAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitScheduleConfig) {
28+
return null;
29+
}
30+
31+
try {
32+
$key = $subject->getKey() ?? 'Unknown Config';
33+
$id = $subject->getId() ?? 'unknown';
34+
$summit = $subject->getSummit();
35+
$summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit';
36+
$is_default = $subject->getIsDefault() ? 'default' : 'non-default';
37+
$color_source = $subject->getColorSource() ?? 'Unknown';
38+
39+
switch ($this->event_type) {
40+
case IAuditStrategy::EVENT_ENTITY_CREATION:
41+
return sprintf(
42+
"Schedule Config '%s' (%d) created for Summit '%s' (%s, color source: %s) by user %s",
43+
$key,
44+
$id,
45+
$summit_name,
46+
$is_default,
47+
$color_source,
48+
$this->getUserInfo()
49+
);
50+
51+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
52+
$change_details = $this->buildChangeDetails($change_set);
53+
return sprintf(
54+
"Schedule Config '%s' (%d) for Summit '%s' updated: %s by user %s",
55+
$key,
56+
$id,
57+
$summit_name,
58+
$change_details,
59+
$this->getUserInfo()
60+
);
61+
62+
case IAuditStrategy::EVENT_ENTITY_DELETION:
63+
return sprintf(
64+
"Schedule Config '%s' (%d) for Summit '%s' was deleted by user %s",
65+
$key,
66+
$id,
67+
$summit_name,
68+
$this->getUserInfo()
69+
);
70+
}
71+
} catch (\Exception $ex) {
72+
Log::warning("SummitScheduleConfigAuditLogFormatter error: " . $ex->getMessage());
73+
}
74+
75+
return null;
76+
}
77+
}
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\summit\SummitSchedulePreFilterElementConfig;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitSchedulePreFilterElementConfigAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitSchedulePreFilterElementConfig) {
28+
return null;
29+
}
30+
31+
try {
32+
$id = $subject->getId() ?? 'unknown';
33+
$type = $subject->getType() ?? 'Unknown Type';
34+
35+
$schedule_config = $subject->getConfig();
36+
$config_key = $schedule_config ? ($schedule_config->getKey() ?? 'Unknown Config') : 'Unknown Config';
37+
38+
switch ($this->event_type) {
39+
case IAuditStrategy::EVENT_ENTITY_CREATION:
40+
return sprintf(
41+
"Schedule Pre-Filter Element Config (%d) created for Config '%s' with type '%s' by user %s",
42+
$id,
43+
$config_key,
44+
$type,
45+
$this->getUserInfo()
46+
);
47+
48+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
49+
$change_details = $this->buildChangeDetails($change_set);
50+
return sprintf(
51+
"Schedule Pre-Filter Element Config (%d) for Config '%s' updated: %s by user %s",
52+
$id,
53+
$config_key,
54+
$change_details,
55+
$this->getUserInfo()
56+
);
57+
58+
case IAuditStrategy::EVENT_ENTITY_DELETION:
59+
return sprintf(
60+
"Schedule Pre-Filter Element Config (%d) for Config '%s' was deleted by user %s",
61+
$id,
62+
$config_key,
63+
$this->getUserInfo()
64+
);
65+
}
66+
} catch (\Exception $ex) {
67+
Log::warning("SummitSchedulePreFilterElementConfigAuditLogFormatter error: " . $ex->getMessage());
68+
}
69+
70+
return null;
71+
}
72+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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\Signs\SummitSign;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class SummitSignAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof SummitSign) {
28+
return null;
29+
}
30+
31+
try {
32+
$id = $subject->getId() ?? 'unknown';
33+
$template = $subject->getTemplate() ?? 'Unknown Template';
34+
$location = $subject->getLocation();
35+
$location_name = $location ? ($location->getName() ?? 'Unknown Location') : 'No Location';
36+
$summit = $subject->getSummit();
37+
$summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit';
38+
39+
switch ($this->event_type) {
40+
case IAuditStrategy::EVENT_ENTITY_CREATION:
41+
return sprintf(
42+
"Summit Sign (%d) created for Summit '%s' at Location '%s' with template '%s' by user %s",
43+
$id,
44+
$summit_name,
45+
$location_name,
46+
$template,
47+
$this->getUserInfo()
48+
);
49+
50+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
51+
$change_details = $this->buildChangeDetails($change_set);
52+
return sprintf(
53+
"Summit Sign (%d) for Summit '%s' at Location '%s' updated: %s by user %s",
54+
$id,
55+
$summit_name,
56+
$location_name,
57+
$change_details,
58+
$this->getUserInfo()
59+
);
60+
61+
case IAuditStrategy::EVENT_ENTITY_DELETION:
62+
return sprintf(
63+
"Summit Sign (%d) for Summit '%s' at Location '%s' was deleted by user %s",
64+
$id,
65+
$summit_name,
66+
$location_name,
67+
$this->getUserInfo()
68+
);
69+
}
70+
} catch (\Exception $ex) {
71+
Log::warning("SummitSignAuditLogFormatter error: " . $ex->getMessage());
72+
}
73+
74+
return null;
75+
}
76+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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\TrackTagGroup;
21+
use Illuminate\Support\Facades\Log;
22+
23+
class TrackTagGroupAuditLogFormatter extends AbstractAuditLogFormatter
24+
{
25+
public function format($subject, array $change_set): ?string
26+
{
27+
if (!$subject instanceof TrackTagGroup) {
28+
return null;
29+
}
30+
31+
try {
32+
$name = $subject->getName() ?? 'Unknown Tag Group';
33+
$id = $subject->getId() ?? 'unknown';
34+
$label = $subject->getLabel() ?? $name;
35+
$summit = $subject->getSummit();
36+
$summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit';
37+
38+
switch ($this->event_type) {
39+
case IAuditStrategy::EVENT_ENTITY_CREATION:
40+
return sprintf(
41+
"Track Tag Group '%s' (%d) created for Summit '%s' with label '%s' by user %s",
42+
$name,
43+
$id,
44+
$summit_name,
45+
$label,
46+
$this->getUserInfo()
47+
);
48+
49+
case IAuditStrategy::EVENT_ENTITY_UPDATE:
50+
$change_details = $this->buildChangeDetails($change_set);
51+
return sprintf(
52+
"Track Tag Group '%s' (%d) for Summit '%s' updated: %s by user %s",
53+
$name,
54+
$id,
55+
$summit_name,
56+
$change_details,
57+
$this->getUserInfo()
58+
);
59+
60+
case IAuditStrategy::EVENT_ENTITY_DELETION:
61+
return sprintf(
62+
"Track Tag Group '%s' (%d) for Summit '%s' was deleted by user %s",
63+
$name,
64+
$id,
65+
$summit_name,
66+
$this->getUserInfo()
67+
);
68+
}
69+
} catch (\Exception $ex) {
70+
Log::warning("TrackTagGroupAuditLogFormatter error: " . $ex->getMessage());
71+
}
72+
73+
return null;
74+
}
75+
}

0 commit comments

Comments
 (0)