當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。