本文整理匯總了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;
}