PHP Timestampable - update and create for one single field, possible?

Viewed 649

I have two fields in my entity - $creationDate and $lastUpdate, which I am updating with the help of:

 @Gedmo\Mapping\Annotation\Timestampable(on="create")

and respectively.

 @Gedmo\Mapping\Annotation\Timestampable(on="update")

However, I would like to limit it to one single field. My question is whether there is anything like

 @Gedmo\Mapping\Annotation\Timestampable(on="create, update")

I searched for some online tips on whether it's possible, but failed to identify a workable solution.

1 Answers

Currently, Timestampable annotation from Atlantic18/DoctrineExtensions repository supports only three types of triggers: create, update, and change. With the change trigger you can achieve something similar to what you describe as follows:

@Gedmo\Mapping\Annotation\Timestampable(
    on="change",
    field={"field1", "field2"}
)

where field specifies a list of tracked fields. Unfortunately, there is no way to instruct Timestampable to track all fields implicitly.

Related