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


PHP Url::previous方法代码示例

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


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

示例1: getCreateUpdateResponse

 /**
  * @param ActiveRecord $model
  * @param array $actions Custom actions array in the form of
  * ```php
  * 'name' => function() {
  *
  * }
  * ```
  * @param bool $addDefaultActions If true default actions will be added
  * @return \yii\web\Response
  * @throws BadRequestHttpException
  */
 protected function getCreateUpdateResponse($model, $actions = [], $addDefaultActions = true)
 {
     $defaultActions = [AdminHtml::ACTION_SAVE_AND_STAY => function () use($model) {
         /** @var Controller | CrudControllerTrait $this */
         return $this->redirect(['update', 'id' => $model->getPrimaryKey()]);
     }, AdminHtml::ACTION_SAVE_AND_CREATE => function () use($model) {
         /** @var Controller | CrudControllerTrait $this */
         if ($url = Url::previous($this->createUrlParam)) {
             Url::remember(null, $this->createUrlParam);
             return $this->redirect($url);
         }
         return $this->redirect(['create']);
     }, AdminHtml::ACTION_SAVE_AND_LEAVE => function () use($model) {
         /** @var Controller | CrudControllerTrait $this */
         if ($url = \Yii::$app->request->get('return')) {
             return $this->redirect($url);
         }
         if ($url = Url::previous($this->indexUrlParam)) {
             Url::remember(null, $this->indexUrlParam);
             return $this->redirect($url);
         }
         return $this->redirect(['index']);
     }];
     if ($addDefaultActions) {
         $actions = array_merge($defaultActions, $actions);
     }
     $actionName = \Yii::$app->request->post(AdminHtml::ACTION_BUTTON_NAME, AdminHtml::ACTION_SAVE_AND_LEAVE);
     if (isset($actions[$actionName])) {
         return call_user_func($actions[$actionName]);
     } else {
         throw new BadRequestHttpException('Unknown action: ' . $actionName);
     }
 }
开发者ID:omnilight,项目名称:yz2-admin,代码行数:45,代码来源:CrudControllerTrait.php

示例2: oAuthSuccess

 public function oAuthSuccess($client)
 {
     // get user data from client
     $userAttributes = $client->getUserAttributes();
     $email = $userAttributes['emails'][0]['value'];
     $player = Player::findByEmail($email);
     if ($player == null) {
         $player = new Player();
         $player->email = $email;
         if (isset($userAttributes['image']) && isset($userAttributes['image']['url'])) {
             $photo = explode('?', $userAttributes['image']['url'])[0];
             $player->photo = $photo;
         }
         if (isset($userAttributes['name'])) {
             $player->first_name = $userAttributes['name']['givenName'];
             $player->last_name = $userAttributes['name']['familyName'];
         }
         $player->generateAuthKey();
         $player->generateAccessToken();
         $player->save();
     }
     if (Yii::$app->user->login($player, 3600 * 24 * 30)) {
         return $this->redirect(Url::previous());
     }
 }
开发者ID:kuznetsov0209,项目名称:mercdev-soccer-server,代码行数:25,代码来源:SiteController.php

示例3: actionDelete

 /**
  * Deletes an existing Employee model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     $model->setScenario('change_status');
     $model->delete();
     return $this->redirect(Url::previous());
 }
开发者ID:johnitvn,项目名称:mg075hynlo5793r5gt,代码行数:13,代码来源:EmployeeController.php

示例4: actionIndex

 public function actionIndex($lang = 'id')
 {
     Yii::$app->language = $lang;
     $cookie = new \yii\web\Cookie(['name' => 'lang', 'value' => $lang]);
     \Yii::$app->getResponse()->getCookies()->add($cookie);
     return $this->redirect(Url::previous());
 }
开发者ID:AsiaWebSolution,项目名称:Yii2BasicTemplateADMINLTE,代码行数:7,代码来源:LanguagesController.php

示例5: actionDelete

 /**
  * Deletes an existing Message 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();
     Message::deleteAll(['id' => $id]);
     Yii::$app->getSession()->setFlash('success', Yii::t('admin', 'Entry has been deleted successfully'));
     return $this->redirect(Url::previous());
 }
开发者ID:mistim,项目名称:yii2-basic-kernel,代码行数:13,代码来源:TranslationPublicController.php

示例6: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!isset($this->redirectUrl)) {
         $this->redirectUrl = Url::previous();
     }
 }
开发者ID:bupy7,项目名称:yii2-grid,代码行数:10,代码来源:VisibleColumnsAction.php

示例7: actionIndex

 public function actionIndex()
 {
     if (yii::$app->user->isGuest == true) {
         return $this->render('index');
     } else {
         $this->redirect(Url::previous('safe_url'));
     }
 }
开发者ID:developer-home,项目名称:project777,代码行数:8,代码来源:AuthController.php

示例8: actionUpdate

 /**
  * Updates an existing Books 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()) {
         return $this->redirect(Url::previous());
     }
     return $this->render('update', ['model' => $model]);
 }
开发者ID:Araused,项目名称:books,代码行数:14,代码来源:BooksController.php

示例9: actionDelete

 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     if (!Yii::$app->user->can('isOwner', ['model' => $model])) {
         throw new ForbiddenHttpException('Access denied');
     }
     $model->delete();
     return $this->redirect(Url::previous());
 }
开发者ID:psych88,项目名称:fifa,代码行数:9,代码来源:DefaultController.php

示例10: actionPrevious

 /** 跳转回上一个记住的网页 */
 public function actionPrevious()
 {
     $previous = Url::previous();
     if ($previous) {
         return $this->redirect($previous);
     } else {
         return $this->redirect(['user-aaa/index']);
     }
 }
开发者ID:krissss,项目名称:YunDou-advanced,代码行数:10,代码来源:UserAaaController.php

示例11: actionDelete

 public function actionDelete($id)
 {
     $this->getModule()->detachFile($id);
     if (\Yii::$app->request->isAjax) {
         return json_encode([]);
     } else {
         return $this->redirect(Url::previous());
     }
 }
开发者ID:dlds,项目名称:yii2-attachments,代码行数:9,代码来源:AppAttachmentController.php

示例12: actionUpdate

 /**
  * Updates an existing I18nMessage model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @param string $language
  * @return mixed
  */
 public function actionUpdate($id, $language)
 {
     $model = $this->findModel($id, $language);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(Url::previous('i18n-messages-filter') ?: ['index']);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
开发者ID:gangbo,项目名称:yii2-starter-kit,代码行数:16,代码来源:I18nMessageController.php

示例13: init

 /**
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (!$this->redirectUrl) {
         $this->redirectUrl = Url::previous(self::URL_NAME_INDEX_ACTION);
     }
     if (!is_subclass_of($this->modelClass, BaseActiveRecord::className())) {
         throw new InvalidConfigException("Property 'modelClass': given class extend '" . BaseActiveRecord::className() . "'");
     }
 }
开发者ID:shubnikofff,项目名称:teleport,代码行数:13,代码来源:CrudAction.php

示例14: actionUpdate

 /**
  * Updates an existing Book 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()) {
         $file = UploadedFile::getInstance($model, 'preview');
         if ($model->upload($file) && $model->save()) {
             return $this->redirect(Url::previous());
         }
     }
     return $this->render('update', ['model' => $model, 'authors' => Author::find()->all()]);
 }
开发者ID:AndreyLipin,项目名称:testing,代码行数:17,代码来源:BookController.php

示例15: init

 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (empty($this->gridId) || empty($this->gridManager)) {
         throw new InvalidConfigException('Property "gridId" and "gridManager" must be specified.');
     }
     $this->gridManager = Instance::ensure($this->gridManager, 'bupy7\\grid\\interfaces\\ManagerInterface');
     if (!isset($this->redirectUrl)) {
         $this->redirectUrl = Url::previous();
     }
 }
开发者ID:Insolita,项目名称:yii2-grid,代码行数:15,代码来源:VisibleColumnsAction.php


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