本文整理汇总了PHP中FOS\UserBundle\Model\UserManagerInterface::updateUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManagerInterface::updateUser方法的具体用法?PHP UserManagerInterface::updateUser怎么用?PHP UserManagerInterface::updateUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FOS\UserBundle\Model\UserManagerInterface
的用法示例。
在下文中一共展示了UserManagerInterface::updateUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Creates a user and returns it.
*
* @param string $username
* @param string $password
* @param string $email
* @param bool $active
* @param bool $superadmin
*
* @return \FOS\UserBundle\Model\UserInterface
*/
public function create($username, $password, $email, $active, $superadmin)
{
$discriminator = $this->discriminator;
switch ($this->type) {
case 'staff':
$class = 'Truckee\\MatchBundle\\Entity\\Staff';
break;
case 'admin':
$class = 'Truckee\\MatchBundle\\Entity\\Admin';
break;
case 'volunteer':
$class = 'Truckee\\MatchBundle\\Entity\\Volunteer';
break;
default:
break;
}
$discriminator->setClass($class);
$user = $this->userManager->createUser();
$user->setUsername($username);
$user->setFirstname($this->firstname);
$user->setLastname($this->lastname);
$user->setEmail($email);
$user->setPlainPassword($password);
$user->setEnabled((bool) $active);
$this->userManager->updateUser($user, true);
return $user;
}
示例2: onSuccess
/**
* @param UserInterface $user
*/
protected function onSuccess(UserInterface $user)
{
if ($this->getNewPassword() != "") {
$user->setPlainPassword($this->getNewPassword());
}
$this->userManager->updateUser($user);
}
示例3: updateObject
/**
* Updates the given user object.
*
* @param DataEvent $event
*/
public function updateObject(DataEvent $event)
{
$object = $event->getData();
if ($object instanceof UserInterface) {
$this->userManager->updateUser($object);
$this->eventDispatcher->dispatch(Events::POST_UPDATE, $event);
$event->stopPropagation();
}
}
示例4: onSecurityInteractiveLogin
/**
* handle user Ip log to users table, after login, with security.interactive_login kernel event.
*
* @param InteractiveLoginEvent $event
*/
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
$user = $event->getAuthenticationToken()->getUser();
if ($user instanceof UserInterface) {
$ipAddress = $this->requestStack->getCurrentRequest()->server->get('REMOTE_ADDR');
$user->setLastloginClientIp($ipAddress);
$this->userManager->updateUser($user);
}
}
示例5: createUserFromResponse
/**
* Create user from response
*
* @param UserResponseInterface $response
*
* @return User
*/
private function createUserFromResponse(UserResponseInterface $response)
{
/** @var User $user User */
$user = $this->userManager->createUser();
$user->setUsername($response->getUsername())->setFullName($response->getRealName())->setEmail($response->getEmail())->setEnabled(true)->setPlainPassword(uniqid())->setFacebookId($response->getUsername())->setFacebookAccessToken($response->getAccessToken());
$this->eventDispatcher->dispatch(AppEvents::FACEBOOK_USER_CONNECTED, new FacebookUserConnectedEvent($user));
$this->userManager->updateUser($user);
return $user;
}
示例6: closeAccount
public function closeAccount(Response $response)
{
$user = $this->securityContext->getToken()->getUser();
$user->setEnabled(false);
$this->userManager->updateUser($user);
$cookieHandler = new CookieClearingLogoutHandler($this->request->cookies->all());
$cookieHandler->logout($this->request, $response, $this->securityContext->getToken());
$sessionHandler = new SessionLogoutHandler();
$sessionHandler->logout($this->request, $response, $this->securityContext->getToken());
$this->securityContext->setToken(null);
}
示例7: create
/**
* Creates a user and returns it.
*
* @param string $email
* @param string $password
* @param string $fullname
* @param string $institution
* @param bool $active
* @param bool $superadmin
*
* @return User
*/
public function create($email, $password, $fullname, $institution, $active, $superadmin)
{
$user = $this->userManager->createUser();
$user->setEmail($email);
$user->setPlainPassword($password);
$user->setFullname($fullname);
$user->setInstitution($institution);
$user->setEnabled($active);
$user->setSuperAdmin($superadmin);
$this->userManager->updateUser($user);
return $user;
}
示例8: create
/**
* Creates a user and returns it.
*
* @param string $username
* @param string $password
* @param string $email
* @param Boolean $active
* @param Boolean $superadmin
*
* @return \FOS\UserBundle\Model\UserInterface
*/
public function create($username, $password, $email, $active, $superadmin)
{
$user = $this->userManager->createUser();
$user->setUsername($username);
$user->setName($this->name);
$user->setSurname($this->surname);
$user->setEmail($email);
$user->setPlainPassword($password);
$user->setEnabled((bool) $active);
$this->userManager->updateUser($user, true);
return $user;
}
示例9: loadUserByOAuthUserResponse
/**
* {@inheritDoc}
*/
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
$username = $response->getUsername();
$user = $this->userManager->findUserBy(array('githubId' => $username));
if (!$user) {
throw new AccountNotLinkedException(sprintf('No user with github username "%s" was found.', $username));
}
if (!$user->getGithubToken()) {
$user->setGithubToken($response->getAccessToken());
$this->userManager->updateUser($user);
}
return $user;
}
示例10: onSuccess
protected function onSuccess()
{
if ($this->confirmation) {
$user->setEnabled(false);
$this->mailer->sendConfirmationEmailMessage($this->user);
} else {
$user->setConfirmationToken(null);
$user->setEnabled(true);
}
$user->setRoles(array('ROLE_ADMIN'));
$user->setPermissions(array('VIEW', 'EDIT', 'CREATE', 'DELETE'));
$this->userManager->updateUser($this->user, true);
}
示例11: create
/**
* Creates a user and returns it.
*
* @param string $username
* @param string $password
* @param string $email
* @param Boolean $active
* @param Boolean $superadmin
* @param string $firstName
* @param string $lastName
* @param integer $phoneNumber
*
* @return \AppBundle\Entity\Users
*/
public function create($username, $password, $email, $active, $superadmin, $firstName, $lastName, $phoneNumber)
{
$user = new Users();
$user->setUsername($username);
$user->setEmail($email);
$user->setPlainPassword($password);
$user->setEnabled((bool) $active);
$user->setFirstName($firstName);
$user->setLastName($lastName);
$user->setPhoneNumber($phoneNumber);
$user->setSuperAdmin((bool) $superadmin);
$this->userManager->updateUser($user);
return $user;
}
示例12: connect
/**
* {@inheritDoc}
*/
public function connect($user, UserResponseInterface $response)
{
$property = $this->getProperty($response);
$setter = 'set' . ucfirst($property);
if (!method_exists($user, $setter)) {
throw new \RuntimeException(sprintf("Class '%s' should have a method '%s'.", get_class($user), $setter));
}
$username = $response->getUsername();
if (null !== ($previousUser = $this->userManager->findUserBy(array($property => $username)))) {
$previousUser->{$setter}(null);
$this->userManager->updateUser($previousUser);
}
$user->{$setter}($username);
$this->userManager->updateUser($user);
}
示例13: unlock
public function unlock(User $user, $username, $password)
{
$user->setUsername($username);
$user->setPlainPassword($password);
$user->setUnlockToken(null);
$errors = $this->validator->validate($user, ['Registration']);
if ($errors->count() === 0) {
try {
$this->userManager->updateUser($user);
} catch (\Exception $e) {
throw new Exception($e->getMessage());
}
return true;
}
return $errors;
}
示例14: create
/**
* Creates a user and returns it.
*
* @param string $username
* @param string $password
* @param string $email
* @param string $name
* @param string $lastName
* @param bool $active
* @param bool $superadmin
*
* @return \FOS\UserBundle\Model\UserInterface
*/
public function create($username, $password, $email, $name, $lastName, $active, $superadmin, $changePassword)
{
$user = $this->userManager->createUser();
$user->setUsername($username);
$user->setEmail($email);
$user->setPlainPassword($password);
$user->setName($name);
$user->setLastName($lastName);
$user->setEnabled((bool) $active);
$user->setSuperAdmin((bool) $superadmin);
if ((bool) $changePassword) {
$user->setPasswordExpireAt(new \DateTime());
}
$this->userManager->updateUser($user);
return $user;
}
示例15: onKernelView
/**
* Persists, updates or delete data return by the controller if applicable.
*
* @param GetResponseForControllerResultEvent $event
*/
public function onKernelView(GetResponseForControllerResultEvent $event)
{
$user = $event->getControllerResult();
if (!$user instanceof UserInterface) {
return;
}
switch ($event->getRequest()->getMethod()) {
case Request::METHOD_POST:
case Request::METHOD_PUT:
$this->userManager->updateUser($user, false);
break;
case Request::METHOD_DELETE:
$this->userManager->deleteUser($user);
$event->setControllerResult(null);
break;
}
}