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


PHP Adm::redirect方法代码示例

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


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

示例1: actionUpdate

 /**
  * Updates an existing ContactMsg model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
         return Adm::redirect(['update', 'id' => $model->id]);
     }
     return $this->render('update', ['model' => $model]);
 }
开发者ID:pavlinter,项目名称:yii2-adm-app,代码行数:15,代码来源:ContactMsgController.php

示例2: actionIndex

 /**
  * @return string
  */
 public function actionIndex()
 {
     $module = Module::getInstance();
     /* @var $model \app\modules\admlivechat\models\SettingsForm */
     $model = $module->manager->createSettingsForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->save()) {
             Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
             return Adm::redirect(['index']);
         }
     }
     return $this->render('index', ['model' => $model]);
 }
开发者ID:pavlinter,项目名称:yii2-app-core,代码行数:16,代码来源:DefaultController.php

示例3: actionUpdate

 /**
  * Updates an existing Page model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @param null|integer $id_parent
  * @return mixed
  */
 public function actionUpdate($id, $id_parent = null)
 {
     $model = $this->findModel($id);
     $model->setLangScenario('update-page-lang');
     if ($model->loadAll(Yii::$app->request->post()) && $model->validateAll()) {
         if ($model->saveAll(false)) {
             Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
             if (!$id_parent) {
                 $id_parent = 0;
             }
             return Adm::redirect(['update', 'id' => $model->id, 'id_parent' => $id_parent]);
         }
     }
     return $this->render('update', ['model' => $model, 'id_parent' => $id_parent]);
 }
开发者ID:pavlinter,项目名称:yii2-adm-pages2,代码行数:22,代码来源:PageController.php

示例4: actionDelete

 /**
  * Deletes an existing Params model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $this->findModel($id)->delete();
     Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully removed!'));
     return Adm::redirect(['index']);
 }
开发者ID:pavlinter,项目名称:yii2-adm-params,代码行数:12,代码来源:ParamsController.php

示例5: actionLogout

 /**
  * @inheritdoc
  */
 public function actionLogout()
 {
     Adm::getInstance()->user->logout(false);
     return Adm::redirect(['login']);
 }
开发者ID:richardcj,项目名称:yii2-adm,代码行数:8,代码来源:DefaultController.php

示例6: actionUpdate

 /**
  * Updates an existing User model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param null $id
  * @return string|\yii\web\Response
  * @throws ForbiddenHttpException
  * @throws NotFoundHttpException
  * @throws \yii\base\InvalidConfigException
  */
 public function actionUpdate($id = null)
 {
     if ($id === null) {
         $id = Adm::getInstance()->user->getId();
     }
     /* @var $model \pavlinter\adm\models\User */
     $model = $this->findModel($id);
     if (Adm::getInstance()->user->can('Adm-UpdateOwnUser', $model)) {
         $model->setScenario('adm-updateOwn');
     } elseif (Adm::getInstance()->user->can('AdmRoot')) {
         $model->setScenario('adm-update');
     } else {
         throw new ForbiddenHttpException('Access denied');
     }
     $dynamicModel = DynamicModel::validateData(['password', 'password2'], [[['password', 'password2'], 'string', 'min' => 6], ['password2', 'compare', 'compareAttribute' => 'password']]);
     $post = Yii::$app->request->post();
     if ($model->load($post) && $dynamicModel->load($post)) {
         if ($model->validate() && $dynamicModel->validate()) {
             if (!empty($dynamicModel->password)) {
                 $model->setPassword($dynamicModel->password);
             }
             if (!Adm::getInstance()->user->can('Adm-UpdateOwnUser', $model)) {
                 //AdmRoot
                 $auth = Yii::$app->authManager;
                 $roles = Yii::$app->request->post('roles', []);
                 $auth->revokeAll($model->id);
                 //remove all assignments
                 if (in_array('AdmRoot', $roles) || in_array('AdmAdmin', $roles)) {
                     $model->role = \app\models\User::ROLE_ADM;
                 } else {
                     $model->role = \app\models\User::ROLE_USER;
                 }
                 foreach ($roles as $role) {
                     $newRole = $auth->createRole($role);
                     $auth->assign($newRole, $model->id);
                 }
             }
             $model->save(false);
             Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
             if (Adm::getInstance()->user->can('Adm-UpdateOwnUser', $model)) {
                 return $this->refresh();
             } else {
                 //AdmRoot
                 return Adm::redirect(['update', 'id' => $model->id]);
             }
         }
     }
     return $this->render('update', ['model' => $model, 'dynamicModel' => $dynamicModel]);
 }
开发者ID:pavlinter,项目名称:yii2-app-core,代码行数:58,代码来源:UserController.php

示例7: actionTest

 /**
  * @return \yii\web\Response
  */
 public function actionTest()
 {
     $error = Module::getInstance()->manager->createEmailConfigQuery('eachEmail', function ($email) {
         try {
             Yii::$app->mailer->compose()->setTo($email)->setFrom(Yii::$app->params['adminEmailName'])->setSubject(Adm::t('adm_email_config', 'Test subject', ['dot' => false]))->setHtmlBody(Adm::t('adm_email_config', 'Test text', ['dot' => false]))->send();
         } catch (\Exception $e) {
             if ($e instanceof \Swift_RfcComplianceException) {
                 Yii::$app->getSession()->setFlash('error', Adm::t('adm_email_config', 'Maybe incorrect email address: {error}', ['error' => $e->getMessage(), 'dot' => true]));
             } else {
                 Yii::$app->getSession()->setFlash('error', Adm::t('adm_email_config', 'Error: {error}', ['error' => $e->getMessage(), 'dot' => true]));
             }
             return true;
         }
     });
     if ($error) {
         Yii::$app->getSession()->removeFlash('success');
     } else {
         Yii::$app->getSession()->setFlash('success', Adm::t('adm_email_config', 'Email sent!', ['dot' => true]));
     }
     return Adm::redirect(['update']);
 }
开发者ID:pavlinter,项目名称:yii2-adm-email-config,代码行数:24,代码来源:EconfigController.php


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