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


PHP Finder::className方法代码示例

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


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

示例1: init

 /** @inheritdoc */
 public function init()
 {
     $this->finder = \Yii::$container->get(Finder::className());
     $this->mailer = \Yii::$container->get(Mailer::className());
     $this->module = \Yii::$app->getModule('user');
     parent::init();
 }
开发者ID:sasaandonov,项目名称:ims,代码行数:8,代码来源:User.php

示例2: 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

示例3: testLogin

 /**
  * Tests login method.
  */
 public function testLogin()
 {
     $user = \Yii::createObject(User::className());
     test::double(Finder::className(), ['findUserByUsernameOrEmail' => $user]);
     $form = Yii::createObject(LoginForm::className());
     $form->beforeValidate();
     test::double($form, ['validate' => false]);
     verify($form->login())->false();
     test::double($form, ['validate' => true]);
     test::double(\yii\web\User::className(), ['login' => false]);
     verify($form->login())->false();
     test::double(\yii\web\User::className(), ['login' => true]);
     verify($form->login())->true();
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:17,代码来源:LoginFormTest.php

示例4: actionSetupAdminUser

 /**
  * Setup admin user (create, update password, confirm)
  */
 public function actionSetupAdminUser()
 {
     $finder = \Yii::$container->get(Finder::className());
     $admin = $finder->findUserByUsername('admin');
     if ($admin === null) {
         $email = $this->prompt('E-Mail for application admin user:', ['default' => getenv('APP_ADMIN_EMAIL')]);
         $this->action('user/create', [$email, 'admin']);
         $password = $this->prompt('Password for application admin user:', ['default' => getenv('APP_ADMIN_PASSWORD')]);
     } else {
         $password = $this->prompt('Update password for application admin user (leave empty to skip):');
     }
     if ($password) {
         $this->action('user/password', ['admin', $password]);
     }
     sleep(1);
     // confirmation may not succeed without a short pause
     $this->action('user/confirm', ['admin']);
 }
开发者ID:Quexer69,项目名称:app,代码行数:21,代码来源:AppController.php

示例5: testRecoveryRequest

 /**
  * Tests recovery request form.
  */
 public function testRecoveryRequest()
 {
     $mailer = test::double(Mailer::className(), ['sendRecoveryMessage' => true]);
     $form = Yii::createObject(['class' => RecoveryForm::className(), 'scenario' => 'request']);
     $this->specify('form is not valid when email is empty', function () use($form) {
         $form->setAttributes(['email' => '']);
         verify($form->validate())->false();
         verify($form->getErrors('email'))->contains('Email cannot be blank.');
     });
     $this->specify('form is not valid when email is incorrect', function () use($form) {
         $form->setAttributes(['email' => 'foobar']);
         verify($form->validate())->false();
         verify($form->getErrors('email'))->contains('Email is not a valid email address.');
     });
     $this->specify('form is not valid when user does not exist', function () use($form) {
         test::double(ActiveQuery::className(), ['exists' => false]);
         $form->setAttributes(['email' => 'foobar@example.com']);
         verify($form->validate())->false();
         verify($form->getErrors('email'))->contains('There is no user with this email address');
         test::double(ActiveQuery::className(), ['exists' => true]);
     });
     $this->specify('form is not valid when user is not confirmed', function () use($form) {
         $user = \Yii::createObject(User::className());
         test::double($user, ['getIsConfirmed' => false]);
         test::double(Finder::className(), ['findUserByEmail' => $user]);
         $form->setAttributes(['email' => 'foobar@example.com']);
         verify($form->validate())->false();
         verify($form->getErrors('email'))->contains('You need to confirm your email address');
         test::double($user, ['getIsConfirmed' => true]);
         verify($form->validate())->true();
     });
     $this->specify('sendRecoveryMessage return true if validation succeeded', function () use($form, $mailer) {
         test::double($form, ['validate' => true]);
         $token = test::double(Token::className(), ['save' => true]);
         $user = \Yii::createObject(['class' => User::className(), 'id' => 1]);
         test::double(Finder::className(), ['findUserByEmail' => $user]);
         verify($form->sendRecoveryMessage())->true();
         $token->verifyInvoked('save');
         verify(\Yii::$app->session->getFlash('info'))->equals('An email has been sent with instructions for resetting your password');
         $mailer->verifyInvoked('sendRecoveryMessage');
     });
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:45,代码来源:RecoveryFormTest.php

示例6: bootstrap

 /** @inheritdoc */
 public function bootstrap($app)
 {
     /** @var Module $module */
     /** @var \yii\db\ActiveRecord $modelName */
     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';
             }
             $configUrlRule['class'] = 'yii\\web\\GroupUrlRule';
             $rule = Yii::createObject($configUrlRule);
             $app->urlManager->addRules([$rule], false);
             if (!$app->has('authClientCollection')) {
                 $app->set('authClientCollection', ['class' => Collection::className()]);
             }
         }
         if (!isset($app->get('i18n')->translations['user*'])) {
             $app->get('i18n')->translations['user*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
         }
         Yii::$container->set('dektrium\\user\\Mailer', $module->mailer);
     }
 }
开发者ID:88c,项目名称:yii2-user,代码行数:40,代码来源:Bootstrap.php

示例7: getFinder

 /**
  * @return Finder
  */
 protected static function getFinder()
 {
     if (static::$finder === null) {
         static::$finder = Yii::$container->get(Finder::className());
     }
     return static::$finder;
 }
开发者ID:GrowlMediaLtd,项目名称:yii2-user,代码行数:10,代码来源:Account.php

示例8: getFinder

 /**
  * @return Finder
  * @throws \yii\base\InvalidConfigException
  */
 protected function getFinder()
 {
     return Yii::$container->get(Finder::className());
 }
开发者ID:andripratama,项目名称:trip-system,代码行数:8,代码来源:User.php

示例9: finder

 public static function finder()
 {
     $finder = Yii::createObject(Finder::className());
     return $finder;
 }
开发者ID:aldife,项目名称:yii2-work-schedule,代码行数:5,代码来源:Help.php


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