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


PHP Module::t方法代码示例

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


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

示例1: run

 public function run()
 {
     $request = Yii::$app->request;
     $user = Yii::createObject($this->modelClass, ['scenario' => $this->scenario]);
     $profile = Yii::createObject($this->profileClass);
     $roles = [];
     if ($this->roleArray !== null) {
         $roles = call_user_func($this->roleArray, $this);
     }
     $roleArray = ArrayHelper::map($roles, 'name', 'description');
     $statusArray = [];
     if ($this->statusArray !== null) {
         $statusArray = call_user_func($this->statusArray, $this);
     }
     if ($user->load($request->post()) && $profile->load($request->post())) {
         if ($user->validate() && $profile->validate()) {
             $user->populateRelation('profile', $profile);
             if ($user->save(false)) {
                 $this->trigger('success', new Event(['data' => $user]));
                 return $this->controller->redirect(Url::to([$this->updateRoute, 'id' => $user->id]));
             } else {
                 $this->trigger('success', new Event(['data' => Module::t('admin', 'Failed create user')]));
                 return $this->controller->refresh();
             }
         } elseif ($request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return array_merge(ActiveForm::validate($user), ActiveForm::validate($profile));
         }
     }
     return $this->render(compact(['user', 'profile', 'roleArray', 'statusArray']));
 }
开发者ID:artkost,项目名称:yii2-starter-kit,代码行数:31,代码来源:CreateAction.php

示例2: actionCreate

 public function actionCreate()
 {
     $username = $this->prompt(Module::t('console', 'Username:'));
     $email = $this->prompt(Module::t('console', 'Email:'));
     $password = $this->prompt(Module::t('console', 'Password:'));
     $name = $this->prompt(Module::t('console', 'First Name:'));
     $surname = $this->prompt(Module::t('console', 'Last Name:'));
     $sex = $this->confirm(Module::t('console', 'Male ?'), 1);
     if ($username && $email && $password) {
         $user = $this->insertUser($username, $email, $password);
         $id = $user->id;
         $this->stdout('Added user with:' . PHP_EOL);
         $this->stdout('ID:', Console::FG_GREY);
         $this->stdout($id . PHP_EOL, Console::FG_YELLOW);
         $this->stdout('Username:', Console::FG_GREY);
         $this->stdout($username . PHP_EOL, Console::FG_YELLOW);
         $this->stdout('Email:', Console::FG_GREY);
         $this->stdout($email . PHP_EOL, Console::FG_YELLOW);
         $this->stdout('Password:', Console::FG_GREY);
         $this->stdout($password . PHP_EOL, Console::FG_YELLOW);
         if ($id && $name && $surname && $sex) {
             $this->insertProfile($id, $name, $surname, $sex);
         }
     }
 }
开发者ID:artkost,项目名称:yii2-starter-kit,代码行数:25,代码来源:ManagerController.php

示例3: actionInit

 /**
  * Create php file for rbac directory
  * Set directory config common.php
  * section components authManager
  */
 public function actionInit()
 {
     $auth = Yii::$app->authManager;
     $auth->removeAll();
     //удаляем старые данные
     //Создадим права доступа к управлению пользователями
     $blog = $auth->createPermission('manageUsers');
     $blog->description = Module::t('module', 'RBAC_MANAGE_USERS');
     $auth->add($blog);
     //Включаем наш обработчик
     $rule = new UserRoleRule();
     $auth->add($rule);
     //Добавляем роли
     $user = $auth->createRole('user');
     $user->description = Module::t('module', 'USER_ROLE_USER');
     $user->ruleName = $rule->name;
     $auth->add($user);
     $moder = $auth->createRole('moder');
     $moder->description = Module::t('module', 'USER_ROLE_MODERATOR');
     $moder->ruleName = $rule->name;
     $auth->add($moder);
     //Добавляем потомков
     $auth->addChild($moder, $user);
     $auth->addChild($moder, $blog);
     $admin = $auth->createRole('admin');
     $admin->description = Module::t('module', 'USER_ROLE_ADMINISTRATOR');
     $admin->ruleName = $rule->name;
     $auth->add($admin);
     $auth->addChild($admin, $moder);
 }
开发者ID:Dominus77,项目名称:yii2-basic-start,代码行数:35,代码来源:RbacController.php

示例4: signup

 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->status = User::STATUS_WAIT;
         $user->generateAuthKey();
         $user->generateEmailConfirmToken();
         if ($user->save()) {
             $auth = Yii::$app->authManager;
             $userRoleDefault = $auth->getRole('user');
             $auth->assign($userRoleDefault, $user->getId());
             $userProfile = new Profile();
             $userProfile->user_id = $user->getId();
             $userProfile->user_agent = Yii::$app->request->getUserAgent();
             $userProfile->user_ip = Yii::$app->request->getUserIP();
             $userProfile->name = $user->username;
             $userProfile->avatar_id = 1;
             //default.png (id = 1)
             $userProfile->save(false);
             Yii::$app->mailer->compose(['text' => '@app/modules/user/mails/emailConfirm'], ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])->setTo($this->email)->setSubject(Module::t('app', 'EMAIL_SIGNUP_SUBJECT') . Yii::$app->name)->send();
         }
         return $user;
     }
     return null;
 }
开发者ID:knyazushka,项目名称:z34lot.new,代码行数:28,代码来源:SignupForm.php

示例5: run

 /**
  * Sign Up page.
  * If record will be successful created, user will be redirected to home page.
  */
 public function run()
 {
     $user = Yii::createObject($this->modelClass, ['scenario' => 'signup']);
     $profile = Yii::createObject($this->profileClass);
     $post = Yii::$app->request->post();
     if ($user->load($post) && $profile->load($post)) {
         if ($user->validate() && $profile->validate()) {
             $user->populateRelation('profile', $profile);
             if ($user->save(false)) {
                 if (Module::param('requireEmailConfirmation', false)) {
                     $this->trigger('success', new Event(['data' => Module::t('model', 'Your account has been created successfully. An email has been sent to you with detailed instructions.', ['url' => Url::to($this->resendRoute)])]));
                 } else {
                     Yii::$app->user->login($user);
                     $this->trigger('success', new Event(['data' => Module::t('model', 'Your account has been created successfully.')]));
                 }
                 return $this->controller->goHome();
             } else {
                 $this->trigger('danger', new Event(['data' => Module::t('model', 'Create account failed. Please try again later.')]));
                 return $this->controller->refresh();
             }
         } elseif (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return array_merge(ActiveForm::validate($user), ActiveForm::validate($profile));
         }
     }
     return $this->render(compact('user', 'profile'));
 }
开发者ID:artkost,项目名称:yii2-starter-kit,代码行数:31,代码来源:SignupAction.php

示例6: validateOldPassword

 /**
  * Validates the password.
  * This method serves as the inline validation for password.
  */
 public function validateOldPassword($attribute, $params)
 {
     $user = $this->getUser();
     if (!$user || !$user->validatePassword($this->{$attribute})) {
         $this->addError($attribute, Module::t('model', 'Invalid old password'));
     }
 }
开发者ID:artkost,项目名称:yii2-starter-kit,代码行数:11,代码来源:Password.php

示例7: validateIsSent

 /**
  * @param string $attribute
  * @param array $params
  */
 public function validateIsSent($attribute, $params)
 {
     if (!$this->hasErrors() && ($user = $this->getUser())) {
         if (User::isPasswordResetTokenValid($user->{$attribute}, $this->_timeout)) {
             $this->addError($attribute, Module::t('module', 'ERROR_TOKEN_IS_SENT'));
         }
     }
 }
开发者ID:AntonBeletsky,项目名称:seokeys,代码行数:12,代码来源:PasswordResetRequestForm.php

示例8: validatePassword

 /**
  * @param string $attribute
  * @param array $params
  */
 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors()) {
         if (!$this->_user->validatePassword($this->{$attribute})) {
             $this->addError($attribute, Module::t('module', 'ERROR_WRONG_CURRENT_PASSWORD'));
         }
     }
 }
开发者ID:oke11o,项目名称:seokeys,代码行数:12,代码来源:PasswordChangeForm.php

示例9: validatePassword

 /**
  * Validates the password.
  * This method serves as the inline validation for password.
  *
  * @param string $attribute the attribute currently being validated
  * @param array $params the additional name-value pairs given in the rule
  */
 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $user = $this->getUser();
         if (!$user || !$user->validatePassword($this->password)) {
             $this->addError($attribute, Module::t('module', 'ERROR_WRONG_LOGIN_OR_PASSWORD'));
         }
     }
 }
开发者ID:MaratCrash,项目名称:3dligatest,代码行数:16,代码来源:LoginForm.php

示例10: run

 /**
  * Activate a new user page.
  *
  * @param string $token Activation token.
  *
  * @return mixed View
  */
 public function run($token)
 {
     $model = Yii::createObject($this->modelClass, ['token' => $token]);
     if ($model->validate() && $model->activate()) {
         $this->trigger('success', new Event(['data' => Module::t('model', 'You successfully activated your account.')]));
     } else {
         $this->trigger('danger', new Event(['data' => Module::t('model', 'Account activation failed.')]));
     }
     return $this->controller->goHome();
 }
开发者ID:artkost,项目名称:yii2-starter-kit,代码行数:17,代码来源:ActivationAction.php

示例11: sendEmail

 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     if ($user = $this->getUser()) {
         $user->generatePasswordResetToken();
         if ($user->save()) {
             return Yii::$app->mailer->compose(['text' => '@app/modules/user/mails/passwordReset'], ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])->setTo($this->email)->setSubject(Module::t('module', 'PASSWORD_RESET_FOR {appName}', ['appName' => Yii::$app->name]))->send();
         }
     }
     return false;
 }
开发者ID:Dominus77,项目名称:blog,代码行数:15,代码来源:PasswordResetRequestForm.php

示例12: actionPassword

 public function actionPassword()
 {
     $user = $this->findModel();
     $model = new PasswordChangeForm($user);
     if ($model->load(Yii::$app->request->post()) && $model->changePassword()) {
         Yii::$app->getSession()->setFlash('success', Module::t('app', 'FLASH_PASSWORD_CHANGE_SUCCESS'));
         return $this->redirect(['index']);
     } else {
         return $this->render('password', ['model' => $model]);
     }
 }
开发者ID:knyazushka,项目名称:z34lot.new,代码行数:11,代码来源:ProfileController.php

示例13: __construct

 /**
  * Creates a form model given a token.
  *
  * @param  string $token
  * @param  array $config
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($token, $config = [])
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException(Module::t('app', 'EMAIL_CONFIRM_CONSTRUCT_BLANK_OR_STRING_TOKEN'));
     }
     $this->_user = User::findByEmailConfirmToken($token);
     if (!$this->_user) {
         throw new InvalidParamException(Module::t('app', 'EMAIL_CONFIRM_CONSTRUCT_WRONG_TOKEN'));
     }
     parent::__construct($config);
 }
开发者ID:knyazushka,项目名称:z34lot.new,代码行数:18,代码来源:EmailConfirmForm.php

示例14: validatePassword

 /**
  * Validates the username and password.
  * This method serves as the inline validation for password.
  */
 public function validatePassword()
 {
     if (!$this->hasErrors()) {
         $user = $this->getUser();
         if (!$user || !$user->validatePassword($this->password)) {
             $this->addError('password', Module::t('module', 'ERROR_WRONG_USERNAME_OR_PASSWORD'));
         } elseif ($user && $user->status == User::STATUS_BLOCKED) {
             $this->addError('username', Module::t('module', 'ERROR_PROFILE_BLOCKED'));
         } elseif ($user && $user->status == User::STATUS_WAIT) {
             $this->addError('username', Module::t('module', 'ERROR_PROFILE_NOT_CONFIRMED'));
         }
     }
 }
开发者ID:Dominus77,项目名称:blog,代码行数:17,代码来源:LoginForm.php

示例15: actionPasswordReset

 public function actionPasswordReset()
 {
     $model = new PasswordResetForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->resetPasword()) {
             Yii::$app->getSession()->setFlash('success', Module::t('module', 'FLASH_PASSWORD_RESET_EMAIL'));
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('error', Module::t('module', 'FLASH_PASSWORD_RESET_ERROR'));
         }
     }
     return $this->render('passwordReset', ['model' => $model]);
 }
开发者ID:MaratCrash,项目名称:3dligatest,代码行数:13,代码来源:DefaultController.php


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