New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Timestampable/Blameable] [RFC] Overhaul of "Trackable" behaviors (Timestampable/Blameable) + inclusion of IpTraceable #208
Comments
nice proposal of you :-) my first thoughts: agreed on current inconsistensy between the different impls. i'd like to see them to "listener only" approach, unless SRP is maintained. i'm not for copying what gedmo does well already, unless we do it better/differently. but this doesn't mean i don't want to see those kind of features landing :-) annotations have been discussed, but i wonder if a pure listener based config wouldn't do the trick. it would fix the SRP problem (define methods in the domain model that makes sense just for an external listener is bad). now i'd be pleased to see those features land, but i wonder if a refactor to try to apply the ideas above would worth it before. thanks and aorry for the delay! |
Hello, Sorry for my late answer. Thank you for your feedback. I will start working on the Consistency part and come back in some time with at least a first PR. I'm doing my best to squeeze it between two projects ;) On the side, I will keep thinking about the flexibility part, see if there is an easy answer (easy meaning with low implementation and maintenance cost). I completely understand your point about not trying to copy Gedmo over and end up with high maintenance cost because of it. |
I'm going through the old issues/PRs and closing most of them so we can focus on now. Thanks for you though, but closing for reasons above. If the bug still remains, please send failing test case to verify it. Only with test we'll be albe to help. |
Hello,
This issue/RFC will include several discussion, but I think it's easier to start with the big picture and break down the discussion if necessary.
I am currently moving away from Stof/Gedmo's Doctrine-Extensions since the bundle doesn't seem to be maintained anymore, and I noticed a few things:
on="change"
behavior)I would like to propose a complete overhaul (separated in a few PRs) solving these issues. However, before starting to work on it, I would like to know if you are interested in such PRs and, if yes, there are a few design choices I would like to discuss.
Consistency
I propose All "Trackable" behaviors use a single Listener.
The Listener would be provided a set of
Callable
s, each providing an associative array of meta-data.On
prePersist
orpreUpdate
events, the sets of all meta-data would be merged together and injected in a new (custom)LifecycleEvent
and given to a method of the behavior Trait. This method would be responsible for actually updating the Entity accordingly.I believe this scenario to fit the philosophy of other behaviors available in the bundle and to be easily extensible if needed.
Flexibility
Since the whole Behaviors system is based on traits and Annotation would be a major disruption, we need to achieve the flexibility in another way.
Granted the consistency mechanism is accepted, I propose the Trackable Trait provides a method
updateConditions
which would return a list of tupples:[tag, event, field, value]
. Theevent
,field
andvalue
are based on Gedmo's system. Soevent
could be either ofcreate
,update
orchange
(Maybeupdate
andchange
could be merged?),field
would be a (set of) field(s) to watch andvalue
a value to wait the given field to change to.The list of conditions would be evaluated by the Listener and appropriate tags would be added to the event meta-data.
The default implementation for each behavior trait would simply provide the default
[["create", "create"], ["update", "update"]]
(These two cases could be abbreviated to[["create"], ["update"]]
or even["create", "update"]
.IP Traceable/Extensivity
Given the consistency proposition is accepted, adding the IP Traceable behavior would be easy enough and rather straight-forward. Same goes for anything else anybody would like to trace (Maybe providing a Symfony Service Tag to annotate callable service could provide easy extension mechanism?)
Conclusion
🏁 Congratulation for making it this far and thanks for your time and attention...
If your are interested by this kind of contributions, I would start working on the PRs as soon as possible. The implementation details of each would be discussed in separated PRs. However, if you have comments on the over all design choices, I would like them to be discussed here.
The text was updated successfully, but these errors were encountered: