[PR #169] [MERGED] preFlush event and lifecycle callback #7810

Open
opened 2026-01-22 15:56:57 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/169
Author: @everzet
Created: 10/23/2011
Status: Merged
Merged: 11/13/2011
Merged by: @beberlei

Base: masterHead: PreFlush-event


📝 Commits (4)

  • 66e2a92 added PreFlush lifetime event and lifecycle callback
  • 20ed886 added test for PreFlush lifetime event
  • 91d8829 removed non-used code
  • 9c4c06c optimized PreFlush (moved into computeChangeSet function)

📊 Changes

6 files changed (+110 additions, -0 deletions)

View changed files

lib/Doctrine/ORM/Event/PreFlushEventArgs.php (+53 -0)
📝 lib/Doctrine/ORM/Events.php (+7 -0)
📝 lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php (+4 -0)
📝 lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php (+6 -0)
📝 lib/Doctrine/ORM/UnitOfWork.php (+10 -0)
📝 tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php (+30 -0)

📄 Description

For now, we have @PrePersist, @PreUpdate and @PreRemove callbacks. But it's not enough, cuz in some cases we need to run some entity method just before every EntityManager#flush() call (examples - translatable behavior and file uploading routines).

I've added and tested new @PreFlush event, which occurs during the start of the EntityManager#flush(), before any changeset gets calculated. This gives users ability to hook into flush process and prepare their entities to save even if they were not changed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/169 **Author:** [@everzet](https://github.com/everzet) **Created:** 10/23/2011 **Status:** ✅ Merged **Merged:** 11/13/2011 **Merged by:** [@beberlei](https://github.com/beberlei) **Base:** `master` ← **Head:** `PreFlush-event` --- ### 📝 Commits (4) - [`66e2a92`](https://github.com/doctrine/orm/commit/66e2a9260e1306d7ffc6bc952a0a890f30916ae4) added PreFlush lifetime event and lifecycle callback - [`20ed886`](https://github.com/doctrine/orm/commit/20ed8869e43cd7f583a75339bca470212a6f199d) added test for PreFlush lifetime event - [`91d8829`](https://github.com/doctrine/orm/commit/91d8829c431b332d357ee8ce95e2f374d45b028e) removed non-used code - [`9c4c06c`](https://github.com/doctrine/orm/commit/9c4c06c42219866b2bb3d99785b2abb2bb7f4952) optimized PreFlush (moved into computeChangeSet function) ### 📊 Changes **6 files changed** (+110 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `lib/Doctrine/ORM/Event/PreFlushEventArgs.php` (+53 -0) 📝 `lib/Doctrine/ORM/Events.php` (+7 -0) 📝 `lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php` (+4 -0) 📝 `lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php` (+6 -0) 📝 `lib/Doctrine/ORM/UnitOfWork.php` (+10 -0) 📝 `tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php` (+30 -0) </details> ### 📄 Description For now, we have `@PrePersist`, `@PreUpdate` and `@PreRemove` callbacks. But it's not enough, cuz in some cases we need to run some entity method just before **every** `EntityManager#flush()` call (examples - translatable behavior and file uploading routines). I've added and tested new `@PreFlush` event, which occurs during the start of the `EntityManager#flush()`, before any changeset gets calculated. This gives users ability to hook into flush process and prepare their entities to save even if they were not changed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 15:56:57 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7810