| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- declare(strict_types=1);
- namespace App\Domain\Audit;
- /**
- * Stable string constants for `audit_log.action`. The value is the
- * "<entity>.<verb>" pair surfaced in the API and the UI's filter
- * dropdown. Kept as constants (not an enum) so adding a new action
- * is a one-line patch and so the values can flow through DBAL without
- * the enum casting boilerplate.
- *
- * `entityType` for each action is the prefix before the dot (e.g.
- * `reporter.created` -> entity_type=reporter); the helper below maps
- * automatically.
- */
- final class AuditAction
- {
- public const REPORTER_CREATED = 'reporter.created';
- public const REPORTER_UPDATED = 'reporter.updated';
- public const REPORTER_DELETED = 'reporter.deleted';
- public const CONSUMER_CREATED = 'consumer.created';
- public const CONSUMER_UPDATED = 'consumer.updated';
- public const CONSUMER_DELETED = 'consumer.deleted';
- public const TOKEN_CREATED = 'token.created';
- public const TOKEN_REVOKED = 'token.revoked';
- public const POLICY_CREATED = 'policy.created';
- public const POLICY_UPDATED = 'policy.updated';
- public const POLICY_DELETED = 'policy.deleted';
- public const CATEGORY_CREATED = 'category.created';
- public const CATEGORY_UPDATED = 'category.updated';
- public const CATEGORY_DELETED = 'category.deleted';
- public const MANUAL_BLOCK_CREATED = 'manual_block.created';
- public const MANUAL_BLOCK_DELETED = 'manual_block.deleted';
- public const ALLOWLIST_CREATED = 'allowlist.created';
- public const ALLOWLIST_DELETED = 'allowlist.deleted';
- public const USER_ROLE_CHANGED = 'user.role_changed';
- public const OIDC_ROLE_MAPPING_CREATED = 'oidc_role_mapping.created';
- public const OIDC_ROLE_MAPPING_DELETED = 'oidc_role_mapping.deleted';
- public const JOB_TRIGGERED = 'job.triggered';
- public static function entityTypeFor(string $action): string
- {
- $dot = strpos($action, '.');
- return $dot === false ? $action : substr($action, 0, $dot);
- }
- }
|