當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Profile::socialSave方法代碼示例

本文整理匯總了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);
 }
開發者ID:efabrikov,項目名稱:chomu,代碼行數:56,代碼來源:User.php


注:本文中的app\models\Profile::socialSave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。