Skip to content

Commit

Permalink
EntityDao always flushes only it's entities (and relations, if needed)
Browse files Browse the repository at this point in the history
  • Loading branch information
fprochazka committed Mar 7, 2013
1 parent b2b02f1 commit a142375
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Kdyby/Doctrine/EntityDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Kdyby;
use Kdyby\Persistence;
use Nette;
use Nette\Utils\Arrays;



Expand Down Expand Up @@ -105,7 +106,11 @@ public function delete($entity, $flush = Persistence\ObjectDao::FLUSH)
protected function flush($flush = Persistence\ObjectDao::FLUSH)
{
if ($flush === Persistence\ObjectDao::FLUSH) {
$this->getEntityManager()->flush();
$em = $this->getEntityManager();
$im = $em->getUnitOfWork()->getIdentityMap();
if (!empty($im[$this->_entityName])) {
$em->flush(Arrays::flatten($im[$this->_entityName]));
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Kdyby/Doctrine/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

/**
* @author Filip Procházka <filip@prochazka.su>
*
* @method flush(array $entity = NULL)
*/
class EntityManager extends Doctrine\ORM\EntityManager
{
Expand Down

0 comments on commit a142375

Please sign in to comment.