DDC-720 - Add support to flush only one entity through EntityManager#flush() #166

Merged
merged 3 commits into from Oct 23, 2011

Conversation

Projects
None yet
3 participants
@beberlei
Member

beberlei commented Oct 22, 2011

Only flush the given entity according to a ruleset that keeps the UoW consistent.

  1. All entities scheduled for insertion, (orphan) removals and changes in collections are processed as well!
  2. Read Only entities are skipped.
  3. Proxies are skipped.
  4. Only if entity is properly managed.
@@ -328,10 +328,10 @@ class EntityManager implements ObjectManager
* @throws Doctrine\ORM\OptimisticLockException If a version check on an entity that
* makes use of optimistic locking fails.
*/
- public function flush()
+ public function flush($entity = null)

This comment has been minimized.

Show comment Hide comment
@asm89

asm89 Oct 22, 2011

Member

The docblock should be updated to contain the new optional param.

@asm89

asm89 Oct 22, 2011

Member

The docblock should be updated to contain the new optional param.

lib/Doctrine/ORM/UnitOfWork.php
@@ -255,10 +255,14 @@ class UnitOfWork implements PropertyChangedListener
* 5) All entity deletions
*
*/
- public function commit()
+ public function commit($entity = null)

This comment has been minimized.

Show comment Hide comment
@asm89

asm89 Oct 22, 2011

Member

The docblock should contain the new optional param.

@asm89

asm89 Oct 22, 2011

Member

The docblock should contain the new optional param.

lib/Doctrine/ORM/UnitOfWork.php
@@ -346,6 +350,51 @@ class UnitOfWork implements PropertyChangedListener
$this->scheduledForDirtyCheck =
$this->orphanRemovals = array();
}
+
+ /**
+ * Only flush the given entity according to a rulset that keeps the UoW consistent.

This comment has been minimized.

Show comment Hide comment
@asm89

asm89 Oct 22, 2011

Member

rulset -> ruleset

@asm89

asm89 Oct 22, 2011

Member

rulset -> ruleset

lib/Doctrine/ORM/UnitOfWork.php
+ * 4. Only if entity is properly managed.
+ *
+ * @param Proxy $entity
+ * @return type

This comment has been minimized.

Show comment Hide comment
@asm89

asm89 Oct 22, 2011

Member

No @return?

lib/Doctrine/ORM/UnitOfWork.php
+
+ // Compute changes for INSERTed entities first. This must always happen even in this case.
+ foreach ($this->entityInsertions as $entity) {
+ $class = $this->em->getClassMetadata(get_class($entity));

This comment has been minimized.

Show comment Hide comment
@asm89

asm89 Oct 22, 2011

Member

The $class var from above is overwritten here, but $class is also used below. Is that intentional?

@asm89

asm89 Oct 22, 2011

Member

The $class var from above is overwritten here, but $class is also used below. Is that intentional?

This comment has been minimized.

Show comment Hide comment
@beberlei

beberlei Oct 22, 2011

Member

uh ugly, thanks for the hint

@beberlei

beberlei Oct 22, 2011

Member

uh ugly, thanks for the hint

@jwage

This comment has been minimized.

Show comment Hide comment
@jwage

jwage Oct 22, 2011

Member

Cool! 👍

Member

jwage commented Oct 22, 2011

Cool! 👍

beberlei added a commit that referenced this pull request Oct 23, 2011

Merge pull request #166 from doctrine/DDC-720
DDC-720 - Add support to flush only one entity through EntityManager#flush()

@beberlei beberlei merged commit fd00f2d into master Oct 23, 2011

@Baachi Baachi referenced this pull request in KnpLabs/KnpRadBundle Mar 22, 2013

Merged

Remove $entity from flush method #66

@Ocramius Ocramius deleted the DDC-720 branch Jul 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment