public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $this->eventQueue->setOpened(true);

        $uow = $eventArgs->getEntityManager()->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            if ($entity instanceof ResourceInterface) {
                $this->eventQueue->scheduleInsert($entity);
            }
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            if ($entity instanceof ResourceInterface) {
                $this->eventQueue->scheduleUpdate($entity);
            }
        }

        // TODO move collections before update ?
        foreach ($uow->getScheduledCollectionDeletions() as $col) {
            foreach ($col as $c) {
                foreach ($c as $entity) {
                    if ($entity instanceof ResourceInterface) {
                        $this->eventQueue->scheduleDelete($entity);
                    }
                }
            }
        }
        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            foreach ($col as $c) {
                foreach ($c as $entity) {
                    if ($entity instanceof ResourceInterface) {
                        if ($entity->getId()) {
                            $this->eventQueue->scheduleUpdate($entity);
                        } else {
                            $this->eventQueue->scheduleInsert($entity);
                        }
                    }
                }
            }
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            if ($entity instanceof ResourceInterface) {
                $this->eventQueue->scheduleDelete($entity);
            }
        }

        $this->eventQueue->flush();

        $this->eventQueue->setOpened(false);
    }
public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $this->eventQueue->setOpened(true);

        $uow = $eventArgs->getEntityManager()->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            if ($entity instanceof ResourceInterface) {
                $this->eventQueue->scheduleInsert($entity);
            }
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            if ($entity instanceof ResourceInterface) {
                $this->eventQueue->scheduleUpdate($entity);
            }
        }

        // TODO move collections before update ?
        foreach ($uow->getScheduledCollectionDeletions() as $col) {
            foreach ($col as $c) {
                foreach ($c as $entity) {
                    if ($entity instanceof ResourceInterface) {
                        $this->eventQueue->scheduleDelete($entity);
                    }
                }
            }
        }
        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            foreach ($col as $c) {
                foreach ($c as $entity) {
                    if ($entity instanceof ResourceInterface) {
                        if ($entity->getId()) {
                            $this->eventQueue->scheduleUpdate($entity);
                        } else {
                            $this->eventQueue->scheduleInsert($entity);
                        }
                    }
                }
            }
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            if ($entity instanceof ResourceInterface) {
                $this->eventQueue->scheduleDelete($entity);
            }
        }

        $this->eventQueue->flush();

        $this->eventQueue->setOpened(false);
    }
public function onFlush ( OnFlushEventArgs $ eventArgs ) { $ this -> eventQueue -> setOpened ( true ) ; $ uow = $ eventArgs -> getEntityManager ( ) -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityInsertions ( ) as $ entity ) { if ( $ entity instanceof ResourceInterface ) { $ this -> eventQueue -> scheduleInsert ( $ entity ) ; } } foreach ( $ uow -> getScheduledEntityUpdates ( ) as $ entity ) { if ( $ entity instanceof ResourceInterface ) { $ this -> eventQueue -> scheduleUpdate ( $ entity ) ; } } // TODO move collections before update ? foreach ( $ uow -> getScheduledCollectionDeletions ( ) as $ col ) { foreach ( $ col as $ c ) { foreach ( $ c as $ entity ) { if ( $ entity instanceof ResourceInterface ) { $ this -> eventQueue -> scheduleDelete ( $ entity ) ; } } } } foreach ( $ uow -> getScheduledCollectionUpdates ( ) as $ col ) { foreach ( $ col as $ c ) { foreach ( $ c as $ entity ) { if ( $ entity instanceof ResourceInterface ) { if ( $ entity -> getId ( ) ) { $ this -> eventQueue -> scheduleUpdate ( $ entity ) ; } else { $ this -> eventQueue -> scheduleInsert ( $ entity ) ; } } } } } foreach ( $ uow -> getScheduledEntityDeletions ( ) as $ entity ) { if ( $ entity instanceof ResourceInterface ) { $ this -> eventQueue -> scheduleDelete ( $ entity ) ; } } $ this -> eventQueue -> flush ( ) ; $ this -> eventQueue -> setOpened ( false ) ; }
On flush event handler.

@param OnFlushEventArgs $eventArgs

@see \Doctrine\ORM\UniOfWork::commit
On flush event handler .