Docs / Reference / Attributes

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.

src/Entity/Book.php
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.

#[AuditTransform]

Transforms the value of a property in the changeset of the Doctrine and MongoDB sources.

ConstantValueResult
AuditTransform::HIDDENhidden***
AuditTransform::HASHhashA digest. The entries stay linkable
AuditTransform::KEYED_HASHkeyed_hashA 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.

src/Entity/User.php
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.

src/Audit/SlackOutput.php
use SymfonyCorp\AuditLog\Attribute\AuditName;
use SymfonyCorp\AuditLog\Output\OutputInterface;

#[AuditName('slack')]
final class SlackOutput implements OutputInterface {}