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


PHP User::findIdentity方法代码示例

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


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

示例1: actionProfile

 /**
  * @return string|\yii\web\Response
  */
 public function actionProfile()
 {
     $model = User::findIdentity(\Yii::$app->user->identity->getId());
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['details']);
     }
     return $this->render('profile', ['model' => $model, 'countries' => Shop::countries()]);
 }
开发者ID:vetoni,项目名称:toko,代码行数:11,代码来源:AccountController.php

示例2: changePassword

 /**
  * @return bool
  */
 public function changePassword()
 {
     if (!$this->validate()) {
         return false;
     }
     $user = User::findIdentity(\Yii::$app->user->identity->getId());
     $user->password_hash = User::hashPassword($this->new_password);
     $user->save();
     return true;
 }
开发者ID:vetoni,项目名称:toko,代码行数:13,代码来源:ChangePasswordForm.php

示例3:

                            <div class="col-md-10">
                                <?php 
echo $review->submission->user_agent;
?>
                            </div>
                            <div class="col-md-offset-2 col-md-10"></div>
                        </div>

                        <div class="form-group field-page-name">
                            <p class="control-label col-md-2" ><?php 
echo Yii::t('app', 'User');
?>
</p>
                            <div class="col-md-10">
                                <?php 
if (null !== ($user = \app\modules\user\models\User::findIdentity($review->submission->processed_by_user_id))) {
    ?>
                                    <?php 
    echo $user->getDisplayName();
    ?>
                                <?php 
} else {
    ?>
                                    <?php 
    echo Yii::t('app', 'Guest');
    ?>
                                <?php 
}
?>
                            </div>
                            <div class="col-md-offset-2 col-md-10"></div>
开发者ID:heartshare,项目名称:dotplant2,代码行数:31,代码来源:submission-view.php

示例4: findModel

 /**
  * Find model by ID
  *
  * @param integer|array $id User ID
  *
  * @return User User
  * @throws HttpException 404 error if user was not found
  */
 protected function findModel($id)
 {
     if (is_array($id)) {
         /** @var User $user */
         $model = User::findIdentities($id);
     } else {
         /** @var User $user */
         $model = User::findIdentity($id);
     }
     if ($model !== null) {
         return $model;
     } else {
         throw new HttpException(404);
     }
 }
开发者ID:artkost,项目名称:yii2-starter-kit,代码行数:23,代码来源:PeopleController.php

示例5: actionChangePassword

 /**
  * Action for handling password changing
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionChangePassword()
 {
     /** @var app\modules\user\models\User|\yii\web\IdentityInterface $model */
     $model = User::findIdentity(Yii::$app->user->id);
     if (is_null($model)) {
         throw new NotFoundHttpException();
     }
     $model->scenario = 'changePassword';
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         $formIsValid = $model->validate();
         $passwordIsValid = $model->validatePassword($model->password);
         if (!$passwordIsValid) {
             $model->addError('password', Yii::t('app', 'Wrong password'));
         }
         if ($formIsValid && $passwordIsValid) {
             $model->setPassword($model->newPassword);
             if ($model->save(true, ['password_hash'])) {
                 Yii::$app->session->setFlash('success', Yii::t('app', 'Password has been changed'));
                 return $this->refresh();
             } else {
                 Yii::$app->session->setFlash('error', Yii::t('app', 'Internal error'));
             }
         }
     }
     return $this->render('change-password', ['model' => $model]);
 }
开发者ID:heartshare,项目名称:dotplant2,代码行数:32,代码来源:UserController.php

示例6: date

/**
 * @var bool $allowRate
 * @var \app\models\PropertyGroup[] $groups
 * @var int $index
 * @var string $key
 * @var \app\modules\review\models\Review $model
 * @var \yii\web\View $view
 */
use app\models\Property;
use kartik\helpers\Html;
use kartik\icons\Icon;
if ($model->submission->processed_by_user_id === null) {
    $userName = Yii::t('app', 'Guest');
} else {
    /** @var \app\modules\user\models\User $user */
    $user = \app\modules\user\models\User::findIdentity($model->submission->processed_by_user_id);
    $userName = Html::encode($user->getDisplayName());
}
//$model->submission->getPropertyGroups(true);
?>
<div class="row review">
    <div class="col-md-4">
        <div class="review-date_submitted label label-default">
            <?php 
echo Icon::show('calendar') . date("d.m.Y H:i:s", strtotime($model->submission->date_received));
?>
        </div>
        <div class="review-author">
            <?php 
echo Icon::show('user') . $userName;
?>
开发者ID:yii2ApplicationCollect,项目名称:dotplant2,代码行数:31,代码来源:item.php

示例7:

?>
                <?php 
echo $form->field($model, 'meta_keywords')->textInput();
?>
                <?php 
echo $form->field($model, 'meta_description')->textInput();
?>
            </div>
            <!-- /.tab-pane -->
            <div class="tab-pane" id="tab_2">
                <?php 
$user_id = $model->isNewRecord ? Yii::$app->user->identity->getId() : $model->create_user_id;
echo $form->field($model, 'create_user_id')->staticField(User::findIdentity($user_id)->username)->label(Yii::t('content', 'Create User'));
?>
                <?php 
echo $form->field($model, 'update_user_id')->staticField(User::findIdentity($user_id)->username)->label(Yii::t('content', 'Update User'));
?>
                <?php 
echo $form->field($model, 'published_at')->widget(\oakcms\datetimepicker\DateTime::className());
?>
                <?php 
echo $form->field($model, 'created_at')->staticField(date('d.m.Y H:i', $model->created_at));
?>
                <?php 
echo $form->field($model, 'updated_at')->staticField(date('d.m.Y H:i', $model->updated_at));
?>
                <?php 
echo $form->field($model, 'create_user_ip')->staticField();
?>
                <?php 
echo $form->field($model, 'status')->widget(\oakcms\bootstrapswitch\Switcher::className());
开发者ID:oakcms,项目名称:oakcms,代码行数:31,代码来源:_form.php

示例8: loadUserBy

 /**
  * Loads a user.
  *
  * @param  string $field
  * @param  string $value
  * @return UserInterface
  */
 protected function loadUserBy($field, $value)
 {
     if ($user = YiiUser::findIdentity($value)) {
         return new User(array('id' => $user->id, 'username' => $user->username, 'name' => $user->username, 'email' => $user->email, 'permissions' => ['admin', 'manage_widgetkit']));
     }
 }
开发者ID:oakcms,项目名称:oakcms,代码行数:13,代码来源:UserProvider.php


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