Browse Source

Fixes #11058: Add `$checkAjax` parameter to method `yii\web\Controller::redirect()` which controls redirection in AJAX and PJAX requests

tags/3.0.0-alpha1
Yordan Ivanov 8 years ago committed by Alexander Makarov
parent
commit
0d72e37f3c
  1. 3
      framework/CHANGELOG.md
  2. 10
      framework/web/Controller.php

3
framework/CHANGELOG.md

@ -3,6 +3,8 @@ Yii Framework 2 Change Log
2.1.0 under development 2.1.0 under development
----------------------- -----------------------
- Enh #11058: Add `$checkAjax` parameter to method `yii\web\Controller::redirect()` which controls redirection in AJAX and PJAX requests (ivanovyordan)
- Enh #12592: Optimized `yii\filters\AccessController` on processing accessrules (dynasource) - Enh #12592: Optimized `yii\filters\AccessController` on processing accessrules (dynasource)
- Removed methods marked as deprected in 2.0.x (samdark) - Removed methods marked as deprected in 2.0.x (samdark)
- Chg #10771: Consistent behavior of `run()` method in all framework widgets. All return the result now for better extensibility (pkirill99, cebe) - Chg #10771: Consistent behavior of `run()` method in all framework widgets. All return the result now for better extensibility (pkirill99, cebe)
@ -86,7 +88,6 @@ Yii Framework 2 Change Log
- Enh #12580: Make `yii.js` comply with strict and non-strict javascript mode to allow concatenation with external code (mikehaertl) - Enh #12580: Make `yii.js` comply with strict and non-strict javascript mode to allow concatenation with external code (mikehaertl)
- Enh: Method `yii\console\controllers\AssetController::getAssetManager()` automatically enables `yii\web\AssetManager::forceCopy` in case it is not explicitly specified (pana1990, klimov-paul) - Enh: Method `yii\console\controllers\AssetController::getAssetManager()` automatically enables `yii\web\AssetManager::forceCopy` in case it is not explicitly specified (pana1990, klimov-paul)
2.0.9 July 11, 2016 2.0.9 July 11, 2016
------------------- -------------------

10
framework/web/Controller.php

@ -139,11 +139,17 @@ class Controller extends \yii\base\Controller
* @param integer $statusCode the HTTP status code. Defaults to 302. * @param integer $statusCode the HTTP status code. Defaults to 302.
* See <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html> * See <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html>
* for details about HTTP status code * for details about HTTP status code
*
* @param boolean $checkAjax whether to specially handle AJAX (and PJAX) requests. Defaults to false,
* meaning a `Location` header will be sent, which when received as an AJAX/PJAX response, may NOT cause
* browser redirection. If this is true, the current request is an AJAX or PJAX request, then calling this method
* will cause the browser to redirect to the given URL.
* Takes effect only when request header `X-Ie-Redirect-Compatibility` is absent.
* @return Response the current response object * @return Response the current response object
*/ */
public function redirect($url, $statusCode = 302) public function redirect($url, $statusCode = 302, $checkAjax = true)
{ {
return Yii::$app->getResponse()->redirect(Url::to($url), $statusCode); return Yii::$app->getResponse()->redirect(Url::to($url), $statusCode, $checkAjax);
} }
/** /**

Loading…
Cancel
Save