Updates a user password if a plain password is set
public updatePassword ( FOS\UserBundle\Model\UserInterface $user ) : void | ||
$user | FOS\UserBundle\Model\UserInterface | |
return | void |
/** * This must be called on prePersist and preUpdate if the event is about a * user. * * @param UserInterface $user */ protected function updateUserFields(UserInterface $user) { if (null === $this->userManager) { $this->userManager = $this->container->get('fos_user.user_manager'); } $this->userManager->updateCanonicalFields($user); $this->userManager->updatePassword($user); }
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) { $this->userManager->updateCanonicalFields($entity); $this->userManager->updatePassword($entity); } }
private function handleEvent(LifecycleEventArgs $args) { $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->recomputeSingleDocumentChangeSet($meta, $entity); } } }
/** * This must be called on prePersist and preUpdate if the event is about a * user. * * @param UserInterface $user */ protected function updateUserFields(UserInterface $user) { if (null === $this->userDiscriminator) { $this->userDiscriminator = $this->container->get('rollerworks_multi_user.user_discriminator'); } // Can only use the user manager when there is an user-system active if (null === $this->userDiscriminator->getCurrentUser() || true !== $this->userDiscriminator->getCurrentUserConfig()->getConfig('use_listener', true)) { return; } if (null === $this->userManager) { $this->userManager = $this->container->get('fos_user.user_manager'); } $this->userManager->updateCanonicalFields($user); $this->userManager->updatePassword($user); }