Skip to content

Instantly share code, notes, and snippets.

@davidwindell
Created July 3, 2012 11:53
Show Gist options
  • Save davidwindell/3039313 to your computer and use it in GitHub Desktop.
Save davidwindell/3039313 to your computer and use it in GitHub Desktop.
$app->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, array($this, 'persistEntities'));
public function persistEntities(MvcEvent $e) {
try {
$em = $e->getApplication()->getServiceManager()->get('doctrine.entitymanager.orm_default');
$em->flush();
} catch (\PDOException $exception) {
$e->setError('persist-error')
->setParam('exception', $exception);
$e->getApplication()->getEventManager()->trigger('dispatch.error', $e);
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment