DoctrineExtensions icon indicating copy to clipboard operation
DoctrineExtensions copied to clipboard

Add config options to allow fields to be updated using a setter method.

Open fwolfsjaeger opened this issue 2 years ago • 15 comments

Feature request: #2644

This change is applied in Blameable, IpTraceable, SoftDeleteable & Timestampable annotations. The new attribute "setterMethod" can be passed to specify the setter method to be used for a field. If no setter method is specified, the property value would be set directly as before.

fwolfsjaeger avatar Jul 03 '23 15:07 fwolfsjaeger

I would like to add tests for those changes as well. Do you want a separate/duplicated test for every affected annotation/listener?

fwolfsjaeger avatar Aug 23 '23 06:08 fwolfsjaeger

I'm interested with this functionality.

I hope soon will merged to master.

RomanApunts avatar Sep 13 '23 16:09 RomanApunts

I'm also interested in this functionality. At the moment I override and extend the BlameableListener to add this functionality but it was made final so that wont work for long 😄. Any chance we could have this functionality?

yakobe avatar Nov 27 '23 12:11 yakobe

I'll try to find the time to add tests for the changes this week.

fwolfsjaeger avatar Nov 27 '23 12:11 fwolfsjaeger

Alright, all done:

  • I've rebased the branch,
  • added the missing logic in the SoftDeleteable listener,
  • fixed getting the property name in the annotation drivers
  • and added Unit tests for all 4 annotations.

Let me know if you need anything else ;)

fwolfsjaeger avatar Dec 01 '23 14:12 fwolfsjaeger

Any chance that this PR is getting merged?

Even though there is no BC breaking change right now: I could refactor the changes to auto-detect a setter method by simply checking for setFieldName(). That however could break BC as there's no way to stick to the original way of setting the property directly.

fwolfsjaeger avatar Jan 09 '24 10:01 fwolfsjaeger

I'll rebase the latest changes right away. Many thanks for taking the time to review the changes!

fwolfsjaeger avatar Mar 01 '24 16:03 fwolfsjaeger

Thanks for keeping working into this @fwolfsjaeger, in general I see the code fine, but I would like to avoid empty calls and we were also trying to not working with array references, I don't know how hard would be to make that change.

franmomu avatar Jun 09 '24 10:06 franmomu

Sorry, but I'm no longer using DoctrineExtensions. I've created this and another PR about a year ago. That and the incompatibility with DBAL 4 forced me to just add my own listeners for the 3 attributes I was using.

I'll look into the recent deprecations and requested changes, but it might take some time.

fwolfsjaeger avatar Jun 27 '24 16:06 fwolfsjaeger