mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Add interface for LifecycleEventArgs of PrePersist and PreUpdate #6717
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @VincentLanglet on GitHub (May 12, 2021).
I often use LifecycleCallback for both PrePersist and PreUpdate for similar thing.
A classic example would be
I could write instead something like
But the best would be
In the case of PrePersist,
Maybe the same could be done for other method
@beberlei commented on GitHub (May 13, 2021):
With PHP 8 this could be solved with union types. The two are completly different, so its good that they don't share an interface imho.
@VincentLanglet commented on GitHub (May 14, 2021):
Not really, I'll just be able to type add typehint, but in order to use the
hasChangedFieldmethod, I'll still need to add ainstanceof PreUpdateEventArgscheck.I not fully understand why it's completely different.
If we consider changeset as "The value which need to be persisted/saved/updated" both could have a changeset.
All the value of the new entity which need to be persisted are in the changeset.
Only the change value of the entity updated are in the changeset.