Why do you call $em->flush() everytime you persist? This is against the default usage of Doctrine, where you flush only once per request (ideally). I would instead prefer that flush will be called through an event listener during mvc-lifecycle, or manually in the controller action.
the default usage with zend db could simple implement flush() in the mapper class as empty method doing nothing.
There's really no harm in calling persist here. It's not worth the additional complexity in the hopes that people using this module will hook into the event.
Why do you call $em->flush() everytime you persist? This is against the default usage of Doctrine, where you flush only once per request (ideally). I would instead prefer that flush will be called through an event listener during mvc-lifecycle, or manually in the controller action. the default usage with zend db could simple implement flush() in the mapper class as empty method doing nothing.
See: ZfcUserDoctrineORM\Mapper\UserDoctrine::persist(User $user) { $em = $this->getEntityManager(); $this->events()->trigger(FUNCTION . '.pre', $this, array('user' => $user, 'em' => $em)); $em->persist($user); $this->events()->trigger(FUNCTION . '.post', $this, array('user' => $user, 'em' => $em)); $em->flush(); // why do you call flush here? , }