本文整理汇总了PHP中app\models\Profile::socialSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::socialSave方法的具体用法?PHP Profile::socialSave怎么用?PHP Profile::socialSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Profile
的用法示例。
在下文中一共展示了Profile::socialSave方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findByEAuth
public static function findByEAuth($service)
{
if (!$service->getIsAuthenticated()) {
throw new ErrorException('Не можливо зареєструватися.');
}
$id = $service->getServiceName() . '-' . $service->getId();
/* echo '<pre>';
var_dump($service);die();
echo '</pre>'; */
/* if($service->getServiceName() == 'facebook'){
$email = '';
}elseif($service->getServiceName() == 'odnoklassniki'){
$email = '';
}elseif($service->getServiceName() == 'vkontakte'){
$email = $service->getAttribute('email') ? $service->getAttribute('email') : null;
} */
$attributes = array('social_id' => $id, 'username' => $service->getAttribute('name'), 'auth_key' => md5($id), 'profile' => $service->getAttributes());
$user = static::findOne(['social_id' => $id]);
if (isset($user->social_id)) {
$email = $user->email;
if ($email == '') {
$user->email = '';
$user->save(false);
}
if (strripos($email, '@site.com') !== false) {
if ($service->getServiceName() == 'odnoklassniki') {
$user->email = '';
} else {
$user->email = $service->getAttribute('email');
}
$user->save(false);
}
}
if (!isset($user->social_id)) {
$user = new User();
$user->social_id = $attributes['social_id'];
if (isset($attributes['email'])) {
$user->email = $attributes['email'];
}
$password_hash = $user->generate_password();
$user->setPassword($password_hash);
$user->role = 1;
$user->status = self::STATUS_ACTIVE;
$user->profile = json_encode($service->getAttributes());
$user->save(false);
Profile::socialSave($user, $service->getAttributes());
$user = static::findOne(['social_id' => $id]);
}
$user->profile = $service->getAttributes();
// $user->photoSoc = $service->getAttribute('photo');
self::$role = $user->role;
Yii::$app->user->login($user, 3600);
$attributes['profile']['service'] = $service->getServiceName();
Yii::$app->getSession()->set('user-' . $id, $attributes);
return new self($attributes);
}