本文整理汇总了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;
}