我正在努力制作一些var_dump()
变量$attr = $response->getResponse();
,例如我从google api获取的变量app/log/dev.log for example?
。但我无法做到这一点。
是否可以将其写在public function loadUserByOAuthUserResponse(UserResponseInterface $response) {
$username = $response->getUsername();
$nickname= $response->getNickname();
//$user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));
$user = $this->userManager->findUserBy(array("email" => $response->getEmail()));
$attr = $response->getResponse();
//when the user is registrating
if (null === $user) {
// init some setter functions
$service = $response->getResourceOwner()->getName();
$setter = 'set' . ucfirst($service);
$setter_id = $setter . 'Id';
$setter_token = $setter . 'AccessToken';
// create new user here indepently of which service we are using!
$user = $this->userManager->createUser();
$user->$setter_id($username);
$user->$setter_token($response->getAccessToken());
$user->setUsername($response->getUsername());
//$user->setUsernameCanonical($response->getNickname());
$user->setEmail($response->getEmail());
$user->setEmailCanonical($response->getEmail());
switch ($service) {
case 'facebook':
if (isset($attr['gender'])) {
if ($attr['gender'] == 'male')
$user->setGender(true);
else
$user->setGender(false);
}
if (isset($attr['first_name'])) {
$user->setName($attr['first_name']);
}
if (isset($attr['last_name'])) {
$user->setFamilyname($attr['last_name']);
}
if (isset($attr['location'])) {
if (isset($attr['location']['name'])) {
if ($attr['location']['name']) {
$user->setLocation($attr['location']['name']);
}
}
}
if (isset($attr['hometown'])) {
if (isset($attr['hometown']['name'])) {
if ($attr['hometown']['name']) {
$user->setHometown($attr['hometown']['name']);
}
}
}
if (isset($attr['birthday'])) {
$user->setBirthday(new \DateTime($attr['birthday']));
}
if ($nickname) {
$user->setPassword("aa" . $nickname);
}else $user->setPassword($attr['name']);
break;
case 'google':
if (isset($attr['gender'])) {
if ($attr['gender'] == 'male')
$user->setGender(true);
else
$user->setGender(false);
}
if (isset($attr['birthday'])) {
$user->setPassword($attr['birthday']);
} else $user->setPassword("google on the play");
break;
}
$user->setAccept(true);
$user->setEnabled(true);
// update the user here
$this->userManager->updateUser($user);
return $user;
}
//if user exists - go with the HWIOAuth way
$user = parent::loadUserByOAuthUserResponse($response);
$serviceName = $response->getResourceOwner()->getName();
$setter = 'set' . ucfirst($serviceName) . 'AccessToken';
//update access token
$user->$setter($response->getAccessToken());
return $user;
}
下面是
{{1}}