本文整理汇总了PHP中HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface::getRealname方法的典型用法代码示例。如果您正苦于以下问题:PHP UserResponseInterface::getRealname方法的具体用法?PHP UserResponseInterface::getRealname怎么用?PHP UserResponseInterface::getRealname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface
的用法示例。
在下文中一共展示了UserResponseInterface::getRealname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginUserVK
private function loginUserVK(UserResponseInterface $response)
{
$username = $response->getUsername();
$realname = explode(' ', $response->getRealname());
$firstName = $realname[1];
$lastName = $realname[0];
$email = $this->oAuthToken->getOAuthToken($response)->getRawToken()['email'];
return ['loginField' => 'vkLogin', 'username' => $username, 'firstName' => $firstName, 'lastName' => $lastName, 'gender' => 'male', 'email' => $email];
}
示例2: loadUserByOAuthUserResponse
/**
* Loads the user by a given UserResponseInterface object.
*
* @param UserResponseInterface $response
*
* @return UserInterface
*
* @throws UsernameNotFoundException if the user is not found
*/
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
$em = $this->em;
$type = $response->getResourceOwner()->getName();
$user = $em->getRepository('AppBundle:User')->findOneBy(['email' => $response->getEmail()]);
if ($user === null) {
$user = new User();
$user->setEmail($response->getEmail())->setFirstName($response->getFirstName() ?: $response->getUsername())->setLastName($response->getLastName() ?: $response->getRealname())->setIsActive(true);
$em->persist($user);
$em->flush();
}
if ($type === 'facebook') {
$user->setFacebookToken($response->getAccessToken())->setFacebookId($response->getUsername());
}
if ($type === 'google') {
$user->setGoogleToken($response->getAccessToken())->setGoogleId($response->getUsername());
}
$em->flush();
return $user;
}