当前位置: 首页>>代码示例>>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;未经允许,请勿转载。