本文整理匯總了PHP中HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface::getNickName方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserResponseInterface::getNickName方法的具體用法?PHP UserResponseInterface::getNickName怎麽用?PHP UserResponseInterface::getNickName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface
的用法示例。
在下文中一共展示了UserResponseInterface::getNickName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadUserByOAuthUserResponse
/**
* @inheritdoc
*/
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
try {
$user = $this->userManager->findUser($response->getEmail());
} catch (\Exception $e) {
$username = $response->getEmail();
$firstName = $response->getFirstName() != '' ? $response->getFirstName() : $response->getNickName();
$lastName = $response->getLastName() != '' ? $response->getLastName() : '';
try {
$user = $this->userManager->createNewUser($username, $response->getEmail(), $firstName, $lastName);
} catch (\Exception $e) {
throw $e;
}
}
return new User($user);
}
示例2: loadTwitterUser
protected function loadTwitterUser(UserResponseInterface $response)
{
$user = $this->userManager->createUser();
$user->setUsername($response->getUsername());
$user->setEmail($response->getEmail());
$user->setLastName($response->getRealName());
$user->setFirstName($response->getNickName());
$user->setType($response->getResourceOwner()->getName());
$user->setAccessToken($response->getAccessToken());
$user->setLocale($response->getLocale());
if (is_null($user->getLocale())) {
$user->setLocale('fr');
}
$user->setRoles(['ROLE_USER']);
$user->setPassword('');
$user->setEnabled(true);
$user->setCreatedAt(new \DateTime());
$user->setUpdatedAt(new \DateTime());
$this->userManager->updateUser($user);
return $user;
}