Attributes
The PHP attributes of the bundle, in the SymfonyCorp\AuditLog\Attribute namespace.
#[Auditable]
Marks a class or a method as audited: an entity, a document, a controller, a command, a message or a workflow subject. The matching source must be enabled. Nothing else is recorded.
- Targets: a class or a method.
- On a controller method, only this action is recorded.
use SymfonyCorp\AuditLog\Attribute\Auditable;
#[ORM\Entity]
#[Auditable]
class Book {}#[AuditIgnore]
Excludes a property from the changeset of the Doctrine and MongoDB sources. The value is not recorded.
- Target: a property.
#[AuditTransform]
Transforms the value of a property in the changeset of the Doctrine and MongoDB sources.
- Target: a property.
- Argument:
$transformation, a string. It cannot be empty.
| Constant | Value | Result |
|---|---|---|
AuditTransform::HIDDEN | hidden | *** |
AuditTransform::HASH | hash | A digest. The entries stay linkable |
AuditTransform::KEYED_HASH | keyed_hash | A digest keyed with keyed_hash_secret |
The argument also accepts the #[AuditName] or the service id of your own value transformer. An unknown name fails cache:warmup. Without a cache warmup, for example in development, the field is recorded as *** and a warning is logged.
use SymfonyCorp\AuditLog\Attribute\Auditable;
use SymfonyCorp\AuditLog\Attribute\AuditIgnore;
use SymfonyCorp\AuditLog\Attribute\AuditTransform;
#[Auditable]
class User
{
#[AuditIgnore]
public string $token; // not recorded
#[AuditTransform(AuditTransform::HIDDEN)]
public string $password; // recorded as '***'
#[AuditTransform(AuditTransform::KEYED_HASH)]
public string $email; // recorded as a digest keyed with your secret
#[AuditTransform('mask_email')]
public string $backupEmail; // your own transformer
}See Transformations to choose a transformation.
#[AuditName]
Gives a short name to an output, a reader or a value transformer. Without it, the name is the service id.
- Target: a class.
- Argument:
$name, a string. It cannot be empty. - Use the name of an output or a reader in
--output=<name>and in the EasyAdmin views. Give an output and its reader the same name. - Use the name of a value transformer in
#[AuditTransform]. - The name is explicit, so renaming or moving the class does not change it.
use SymfonyCorp\AuditLog\Attribute\AuditName;
use SymfonyCorp\AuditLog\Output\OutputInterface;
#[AuditName('slack')]
final class SlackOutput implements OutputInterface {}