Permalink
Browse files

Merge pull request #404 from ddebree/master

Fixes #403
  • Loading branch information...
2 parents aabf01d + 111698d commit 9e5f15279d16bbd640018dfb0098beec87b81e13 @stof stof committed Nov 28, 2011
Showing with 34 additions and 12 deletions.
  1. +11 −4 CouchDocument/UserListener.php
  2. +11 −4 Document/UserListener.php
  3. +12 −4 Entity/UserListener.php
@@ -50,14 +50,21 @@ public function preUpdate(LifecycleEventArgs $args)
private function handleEvent(LifecycleEventArgs $args)
{
- if (null === $this->userManager) {
- $this->userManager = $this->container->get('fos_user.user_manager');
- }
-
$document = $args->getDocument();
if ($document instanceof UserInterface) {
+ if (null === $this->userManager) {
+ $this->userManager = $this->container->get('fos_user.user_manager');
+ }
$this->userManager->updateCanonicalFields($document);
$this->userManager->updatePassword($document);
+ if ($args instanceof PreUpdateEventArgs) {
+ // We are doing a update, so we must force Doctrine to update the
+ // changeset in case we changed something above
+ $dm = $args->getDocumentManager();
+ $uow = $dm->getUnitOfWork();
+ $meta = $dm->getClassMetadata(get_class($entity));
+ $uow->recomputeSingleEntityChangeSet($meta, $entity);
+ }
}
}
}
View
@@ -65,14 +65,21 @@ public function preUpdate(PreUpdateEventArgs $args)
private function handleEvent(LifecycleEventArgs $args)
{
- if (null === $this->userManager) {
- $this->userManager = $this->container->get('fos_user.user_manager');
- }
-
$entity = $args->getDocument();
if ($entity instanceof UserInterface) {
+ if (null === $this->userManager) {
+ $this->userManager = $this->container->get('fos_user.user_manager');
+ }
$this->userManager->updateCanonicalFields($entity);
$this->userManager->updatePassword($entity);
+ if ($args instanceof PreUpdateEventArgs) {
+ // We are doing a update, so we must force Doctrine to update the
+ // changeset in case we changed something above
+ $dm = $args->getDocumentManager();
+ $uow = $dm->getUnitOfWork();
+ $meta = $dm->getClassMetadata(get_class($entity));
+ $uow->recomputeSingleEntityChangeSet($meta, $entity);
+ }
}
}
}
View
@@ -65,14 +65,22 @@ public function preUpdate(PreUpdateEventArgs $args)
private function handleEvent(LifecycleEventArgs $args)
{
- if (null === $this->userManager) {
- $this->userManager = $this->container->get('fos_user.user_manager');
- }
-
$entity = $args->getEntity();
if ($entity instanceof UserInterface) {
+ if (null === $this->userManager) {
+ $this->userManager = $this->container->get('fos_user.user_manager');
+ }
+
$this->userManager->updateCanonicalFields($entity);
$this->userManager->updatePassword($entity);
+ if ($args instanceof PreUpdateEventArgs) {
+ // We are doing a update, so we must force Doctrine to update the
+ // changeset in case we changed something above
+ $em = $args->getEntityManager();
+ $uow = $em->getUnitOfWork();
+ $meta = $em->getClassMetadata(get_class($entity));
+ $uow->recomputeSingleEntityChangeSet($meta, $entity);
+ }
}
}
}

0 comments on commit 9e5f152

Please sign in to comment.