3

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.

  • Have you tried using the `"change"` trigger? – Ruslan Osmanov Jun 25 '19 at 10:15
  • I am on it for the last couple of hours, fighting with an issue - "Missing parameters on property - fieldName, field must be set on [change] trigger in class". So far could not achieve any result. – Cheshire Katzzze Jun 25 '19 at 11:03
  • With `"change"` trigger, `field` argument is required. Simply pass a list of field names as follows: `@Gedmo\Timestampable(on="change", field={"field1", "field2"})`. AFAIK, there is no way to instruct Timestampable to include all fields, so the code is going to be a little bit verbose :-/ – Ruslan Osmanov Jun 25 '19 at 11:51
  • Thanks for advice, Ruslan! Already tried it, I get "Timestampable extension does not support multiple value changeset detection yet.", though yes, the error in case is solved by the introduction of the field value. – Cheshire Katzzze Jun 25 '19 at 11:57
  • Please answer separately so that I could mark your answer as the right one. Pitifully, after solving one problem immediately two appear ) Looks like I will have a problem with this Doctrine feature – Cheshire Katzzze Jun 25 '19 at 11:58

1 Answers1

1

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.

Ruslan Osmanov
  • 20,486
  • 7
  • 46
  • 60