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


PHP user\Finder類代碼示例

本文整理匯總了PHP中dektrium\user\Finder的典型用法代碼示例。如果您正苦於以下問題:PHP Finder類的具體用法?PHP Finder怎麽用?PHP Finder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Finder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: bootstrap

 /** @inheritdoc */
 public function bootstrap($app)
 {
     /** @var $module Module */
     if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) {
         $this->_modelMap = array_merge($this->_modelMap, $module->modelMap);
         foreach ($this->_modelMap as $name => $definition) {
             $class = "dektrium\\user\\models\\" . $name;
             \Yii::$container->set($class, $definition);
             $modelName = is_array($definition) ? $definition['class'] : $definition;
             $module->modelMap[$name] = $modelName;
             if (in_array($name, ['User', 'Profile', 'Token', 'Account'])) {
                 \Yii::$container->set($name . 'Query', function () use($modelName) {
                     return $modelName::find();
                 });
             }
         }
         \Yii::$container->setSingleton(Finder::className(), ['userQuery' => \Yii::$container->get('UserQuery'), 'profileQuery' => \Yii::$container->get('ProfileQuery'), 'tokenQuery' => \Yii::$container->get('TokenQuery'), 'accountQuery' => \Yii::$container->get('AccountQuery')]);
         if ($app instanceof ConsoleApplication) {
             $module->controllerNamespace = 'dektrium\\user\\commands';
         } else {
             \Yii::$container->set('yii\\web\\User', ['enableAutoLogin' => true, 'loginUrl' => ['/user/security/login'], 'identityClass' => $module->modelMap['User']]);
             $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules];
             if ($module->urlPrefix != 'user') {
                 $configUrlRule['routePrefix'] = 'user';
             }
             $app->get('urlManager')->rules[] = new GroupUrlRule($configUrlRule);
             if (!$app->has('authClientCollection')) {
                 $app->set('authClientCollection', ['class' => Collection::className()]);
             }
         }
         $app->get('i18n')->translations['user*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
         $defaults = ['welcomeSubject' => \Yii::t('user', 'Welcome to {0}', \Yii::$app->name), 'confirmationSubject' => \Yii::t('user', 'Confirm account on {0}', \Yii::$app->name), 'reconfirmationSubject' => \Yii::t('user', 'Confirm email change on {0}', \Yii::$app->name), 'recoverySubject' => \Yii::t('user', 'Complete password reset on {0}', \Yii::$app->name)];
         \Yii::$container->set('dektrium\\user\\Mailer', array_merge($defaults, $module->mailer));
     }
 }
開發者ID:uniwizardcom,項目名稱:yii2-task,代碼行數:36,代碼來源:Bootstrap.php

示例2: getUser

 /**
  * @return User
  */
 public function getUser()
 {
     if ($this->_user === null) {
         $this->_user = $this->finder->findUserByEmail($this->email);
     }
     return $this->_user;
 }
開發者ID:88c,項目名稱:yii2-user,代碼行數:10,代碼來源:ResendForm.php

示例3: actionShow

 /**
  * Shows user's profile.
  *
  * @param int $id
  *
  * @return \yii\web\Response
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionShow($id)
 {
     $profile = $this->finder->findProfileById($id);
     if ($profile === null) {
         throw new NotFoundHttpException();
     }
     return $this->render('show', ['profile' => $profile]);
 }
開發者ID:chabberwock,項目名稱:halo-dev,代碼行數:16,代碼來源:ProfileController.php

示例4: actionShow

 /**
  * Shows user's profile.
  * @param  integer $id
  * @return \yii\web\Response
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionShow($id)
 {
     $profile = $this->finder->findProfileById($id);
     if ($profile === null) {
         throw new NotFoundHttpException();
     }
     $fi = FirmaIngeniero::find()->where(['ingeniero_id' => $profile->user_id])->one();
     return $this->render('show', ['profile' => $profile, 'fi' => $fi]);
 }
開發者ID:fernandrez,項目名稱:ipcbsas,代碼行數:15,代碼來源:ProfileController.php

示例5: rules

 /** @inheritdoc */
 public function rules()
 {
     return ['emailTrim' => ['email', 'filter', 'filter' => 'trim'], 'emailRequired' => ['email', 'required'], 'emailPattern' => ['email', 'email'], 'emailExist' => ['email', 'exist', 'targetClass' => $this->module->modelMap['User'], 'message' => \Yii::t('user', 'There is no user with this email address')], 'emailUnconfirmed' => ['email', function ($attribute) {
         $this->user = $this->finder->findUserByEmail($this->email);
         if ($this->user !== null && $this->module->enableConfirmation && !$this->user->getIsConfirmed()) {
             $this->addError($attribute, \Yii::t('user', 'You need to confirm your email address'));
         }
     }], 'passwordRequired' => ['password', 'required'], 'passwordLength' => ['password', 'string', 'min' => 6]];
 }
開發者ID:manyoubaby123,項目名稱:imshop,代碼行數:10,代碼來源:RecoveryForm.php

示例6: actionIndex

 public function actionIndex()
 {
     $id = Yii::$app->user->identity->id;
     $profile = $this->finder->findProfileById($id);
     if ($profile === null) {
         throw new NotFoundHttpException();
     }
     $this->view->params['profile'] = $profile;
     return $this->render('index');
 }
開發者ID:benzaiten16,項目名稱:2a106c4df948a65ec7f7d840db7f8fde,代碼行數:10,代碼來源:SiteController.php

示例7: search

 /**
  * @param $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = $this->finder->getUserQuery();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['created_at' => $this->created_at])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['registration_ip' => $this->registration_ip]);
     return $dataProvider;
 }
開發者ID:uniwizardcom,項目名稱:yii2-task,代碼行數:14,代碼來源:UserSearch.php

示例8: actionIndex

 /**
  * Updates user's password to given.
  *
  * @param string $search   Email or username
  * @param string $password New password
  */
 public function actionIndex($search, $password)
 {
     $user = $this->finder->findUserByUsernameOrEmail($search);
     if ($user === null) {
         $this->stdout(Yii::t('user', 'User is not found') . "\n", Console::FG_RED);
     } else {
         if ($user->resetPassword($password)) {
             $this->stdout(Yii::t('user', 'Password has been changed') . "\n", Console::FG_GREEN);
         } else {
             $this->stdout(Yii::t('user', 'Error occurred while changing password') . "\n", Console::FG_RED);
         }
     }
 }
開發者ID:TheManagers,項目名稱:yii2-user,代碼行數:19,代碼來源:PasswordController.php

示例9: actionIndex

 /**
  * Confirms a user by setting confirmed_at field to current time.
  *
  * @param string $search Email or username
  */
 public function actionIndex($search)
 {
     $user = $this->finder->findUserByUsernameOrEmail($search);
     if ($user === null) {
         $this->stdout(Yii::t('user', 'User is not found') . "\n", Console::FG_RED);
     } else {
         if ($user->confirm()) {
             $this->stdout(Yii::t('user', 'User has been confirmed') . "\n", Console::FG_GREEN);
         } else {
             $this->stdout(Yii::t('user', 'Error occurred while confirming user') . "\n", Console::FG_RED);
         }
     }
 }
開發者ID:chabberwock,項目名稱:halo-dev,代碼行數:18,代碼來源:ConfirmController.php

示例10: actionShow

 /**
  * Shows user's profile.
  *
  * @param int $id
  *
  * @return \yii\web\Response
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionShow($id)
 {
     $profile = $this->finder->findProfileById($id);
     $post = Post::getPostByUser($id);
     $tags = array();
     for ($i = 0; $i < count($post->getModels()); $i++) {
         array_push($tags, Post_tags::getTags($post->getModels()[$i]['post_id']));
     }
     if ($profile === null) {
         throw new NotFoundHttpException();
     }
     return $this->render('show', ['profile' => $profile, 'posts' => $post, 'tags' => $tags]);
 }
開發者ID:koakumasd,項目名稱:blogsite,代碼行數:21,代碼來源:ProfileController.php

示例11: search

 /**
  * @param $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = $this->finder->getUserQuery();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->created_at !== null) {
         $date = strtotime($this->created_at);
         $query->andFilterWhere(['between', 'created_at', $date, $date + 3600 * 24]);
     }
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'profileUser', $this->profileUser->name])->andFilterWhere(['registration_ip' => $this->registration_ip]);
     return $dataProvider;
 }
開發者ID:Kolya-an,項目名稱:wemamas,代碼行數:18,代碼來源:UserSearch.php

示例12: resend

 /**
  * Creates new confirmation token and sends it to the user.
  *
  * @return bool
  */
 public function resend()
 {
     if (!$this->validate()) {
         return false;
     }
     $user = $this->finder->findUserByEmail($this->email);
     if ($user instanceof User && !$user->isConfirmed) {
         /** @var Token $token */
         $token = \Yii::createObject(['class' => Token::className(), 'user_id' => $user->id, 'type' => Token::TYPE_CONFIRMATION]);
         $token->save(false);
         $this->mailer->sendConfirmationMessage($user, $token);
     }
     \Yii::$app->session->setFlash('info', \Yii::t('user', 'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.'));
     return true;
 }
開發者ID:damasco,項目名稱:yii2-user,代碼行數:20,代碼來源:ResendForm.php

示例13: actionIndex

 /**
  * Deletes a user.
  *
  * @param string $search Email or username
  */
 public function actionIndex($search)
 {
     if ($this->confirm(\Yii::t('user', 'Are you sure? Deleted user can not be restored'))) {
         $user = $this->finder->findUserByUsernameOrEmail($search);
         if ($user === null) {
             $this->stdout(\Yii::t('user', 'User is not found') . "\n", Console::FG_RED);
         } else {
             if ($user->delete()) {
                 $this->stdout(\Yii::t('user', 'User has been deleted') . "\n", Console::FG_GREEN);
             } else {
                 $this->stdout(\Yii::t('user', 'Error occurred while deleting user') . "\n", Console::FG_RED);
             }
         }
     }
 }
開發者ID:manyoubaby123,項目名稱:imshop,代碼行數:20,代碼來源:DeleteController.php

示例14: beforeValidate

 /** @inheritdoc */
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         if (!empty($this->Login)) {
             $this->user = $this->finder->findUser(['Login' => $this->Login])->one();
             /**
              * Generate password
              */
             $hash = Yii::$app->security->generatePasswordHash($this->Password);
             ////$this->Password = $this->Password . ':' . $hash;
             ////list($password, $hash) = explode(':', $this->Password);
             //                if ($this->user !== null && Yii::$app->getSecurity()->validatePassword($this->Password, $hash) ) {
             //                    $this->user->updateAttributes(['Password' => $hash]);
             //                    echo $this->Password . ':' . $hash. ' OK  ';
             //                }
             //                exit;
         }
         if ($this->user === null) {
             if (CardRecord::check($this->Login)) {
                 $card = CardRecord::findCard($this->Login);
                 if ($card !== null && $card->person) {
                     //                    $this->user = $card->person->ServiceCard ? $card->person : null;
                     $this->user = $card->person;
                     return true;
                 }
             }
             $this->addError('Login', \Yii::t('user', 'Invalid login or password'));
             return false;
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
開發者ID:just-leo,項目名稱:cardgame-serial,代碼行數:36,代碼來源:LoginForm.php

示例15: attemptEmailChange

 /**
  * This method attempts changing user email. If user's "unconfirmed_email" field is empty is returns false, else if
  * somebody already has email that equals user's "unconfirmed_email" it returns false, otherwise returns true and
  * updates user's password.
  *
  * @param  string $code
  * @return bool
  * @throws \Exception
  */
 public function attemptEmailChange($code)
 {
     /** @var Token $token */
     $token = $this->finder->findToken(['user_id' => $this->id, 'code' => $code])->andWhere(['in', 'type', [Token::TYPE_CONFIRM_NEW_EMAIL, Token::TYPE_CONFIRM_OLD_EMAIL]])->one();
     if (empty($this->unconfirmed_email) || $token === null || $token->isExpired) {
         \Yii::$app->session->setFlash('danger', \Yii::t('user', 'Your confirmation token is invalid or expired'));
     } else {
         $token->delete();
         if (empty($this->unconfirmed_email)) {
             \Yii::$app->session->setFlash('danger', \Yii::t('user', 'An error occurred processing your request'));
         } else {
             if (static::find()->where(['email' => $this->unconfirmed_email])->exists() == false) {
                 if ($this->module->emailChangeStrategy == Module::STRATEGY_SECURE) {
                     switch ($token->type) {
                         case Token::TYPE_CONFIRM_NEW_EMAIL:
                             $this->flags |= self::NEW_EMAIL_CONFIRMED;
                             \Yii::$app->session->setFlash('success', \Yii::t('user', 'Awesome, almost there. Now you need to click the confirmation link sent to your old email address'));
                             break;
                         case Token::TYPE_CONFIRM_OLD_EMAIL:
                             $this->flags |= self::OLD_EMAIL_CONFIRMED;
                             \Yii::$app->session->setFlash('success', \Yii::t('user', 'Awesome, almost there. Now you need to click the confirmation link sent to your new email address'));
                             break;
                     }
                 }
                 if ($this->module->emailChangeStrategy == Module::STRATEGY_DEFAULT || $this->flags & self::NEW_EMAIL_CONFIRMED && $this->flags & self::OLD_EMAIL_CONFIRMED) {
                     $this->email = $this->unconfirmed_email;
                     $this->unconfirmed_email = null;
                     \Yii::$app->session->setFlash('success', \Yii::t('user', 'Your email address has been changed'));
                 }
                 $this->save(false);
             }
         }
     }
 }
開發者ID:sasaandonov,項目名稱:ims,代碼行數:43,代碼來源:User.php


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