当前位置: 首页>>代码示例>>PHP>>正文


PHP ClientInterface::retrieveAdditionalData方法代码示例

本文整理汇总了PHP中yii\authclient\ClientInterface::retrieveAdditionalData方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::retrieveAdditionalData方法的具体用法?PHP ClientInterface::retrieveAdditionalData怎么用?PHP ClientInterface::retrieveAdditionalData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\authclient\ClientInterface的用法示例。


在下文中一共展示了ClientInterface::retrieveAdditionalData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

 public function authenticate(ClientInterface $client)
 {
     // find existing user by service
     if ($this->userService !== null) {
         /** @var User $user */
         $user = Yii::createObject(ModelMapHelper::User());
         $user = $user->loadModel($this->userService->user_id);
         $user->login(UsersModule::module()->loginDuration);
     } else {
         // no user for this pair
         // this is the most hard part
         // create user
         /** @var SocialServiceInterface|BaseClient $client */
         $client->retrieveAdditionalData();
         /** @var RegistrationForm $registrationForm */
         $registrationForm = Yii::createObject(ModelMapHelper::RegistrationForm());
         $this->mapServiceAttributes($client, $registrationForm);
         $user = $registrationForm->socialRegister($client);
         if ($user === false) {
             throw new ErrorException("Unable to register user");
         }
         $userService = $this->createService();
         if ($user->save() === false) {
             throw new ErrorException("Unable to save user:" . var_export($user->errors, true));
         }
         $user->link('services', $userService);
         // check if we need to run post-registration
         $user->login(UsersModule::module()->loginDuration);
         // check if there's some required or recommended fields missing
         foreach (UsersModule::module()->requiredUserAttributes as $attribute) {
             if (empty($user->{$attribute})) {
                 Yii::$app->session->setFlash('info', Yii::t('users', 'Please fill required profile fields.'));
                 $this->redirectToProfileUpdate();
                 return;
             }
         }
         foreach (UsersModule::module()->recommendedUserAttributes as $attribute) {
             if (empty($user->{$attribute})) {
                 //! @todo Add limitation on UsersModule::recommendedFieldsMaxPrompts
                 Yii::$app->session->setFlash('info', Yii::t('users', 'Please fill recommended profile fields.'));
                 $this->redirectToProfileUpdate();
                 return;
             }
         }
     }
 }
开发者ID:cheaterBY,项目名称:yii2-users-module,代码行数:46,代码来源:Social.php


注:本文中的yii\authclient\ClientInterface::retrieveAdditionalData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。