mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Renamed fooVar to fooParam for various classes.
This commit is contained in:
@ -267,9 +267,9 @@ Then run command `php codecept.phar run --debug unit/SomeDebugTest` and you will
|
||||
|
||||
[authTimeout] =>
|
||||
[autoRenewCookie] => 1
|
||||
[idVar] => __id
|
||||
[authTimeoutVar] => __expire
|
||||
[returnUrlVar] => __returnUrl
|
||||
[idParam] => __id
|
||||
[authTimeoutParam] => __expire
|
||||
[returnUrlParam] => __returnUrl
|
||||
[_access:yii\web\User:private] => Array
|
||||
(
|
||||
)
|
||||
|
||||
@ -173,7 +173,19 @@ Yii Framework 2 Change Log
|
||||
- Chg: Renamed `ActiveRecordInterface::createActiveRelation()` to `createRelation()` (qiangxue)
|
||||
- Chg: The scripts in asset bundles are now registered in `View` at the end of `endBody()`. It was done in `endPage()` previously (qiangxue)
|
||||
- Chg: Renamed `csrf-var` to `csrf-param` for CSRF header name (Dilip)
|
||||
- Cgh: The directory holding email templates is renamed from `mails` to `mail` (qiangxue)
|
||||
- Chg: The directory holding email templates is renamed from `mails` to `mail` (qiangxue)
|
||||
- Chg: Renamed properties `fooVar` to `fooParam` for various classes (qiangxue)
|
||||
- Renamed `ActiveForm::ajaxVar` to `ajaxParam`
|
||||
- Renamed `Pagination::pageVar` to `pageParam`
|
||||
- Renamed `Sort::sortVar` to `sortParam`
|
||||
- Renamed `yii\web\Request::csrfVar` to `csrfParam`
|
||||
- Renamed `yii\web\Request::methodVar` to `methodParam`
|
||||
- Renamed `UrlManager::routeVar` to `routeParam`
|
||||
- Renamed `yii\web\Session::flashVar` to `flashParam`
|
||||
- Renamed `yii\web\User::idVar` to `idParam`
|
||||
- Renamed `yii\web\User::authTimeoutVar` to `authTimeoutParam`
|
||||
- Renamed `yii\web\User::returnUrlVar` to `returnUrlParam`
|
||||
|
||||
- New #66: [Auth client library](https://github.com/yiisoft/yii2-authclient) OpenId, OAuth1, OAuth2 clients (klimov-paul)
|
||||
- New #706: Added `yii\widgets\Pjax` and enhanced `GridView` to work with `Pjax` to support AJAX-update (qiangxue)
|
||||
- New #1393: [Codeception testing framework integration](https://github.com/yiisoft/yii2-codeception) (Ragazzo)
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
// function ($form, attribute, messages)
|
||||
afterValidate: undefined,
|
||||
// the GET parameter name indicating an AJAX-based validation
|
||||
ajaxVar: 'ajax',
|
||||
ajaxParam: 'ajax',
|
||||
// the type of data that you're expecting back from the server
|
||||
ajaxDataType: 'json'
|
||||
};
|
||||
@ -295,7 +295,7 @@
|
||||
// If the validation is triggered by form submission, ajax validation
|
||||
// should be done only when all inputs pass client validation
|
||||
var $button = data.submitObject,
|
||||
extData = '&' + data.settings.ajaxVar + '=' + $form.prop('id');
|
||||
extData = '&' + data.settings.ajaxParam + '=' + $form.prop('id');
|
||||
if ($button && $button.length && $button.prop('name')) {
|
||||
extData += '&' + $button.prop('name') + '=' + $button.prop('value');
|
||||
}
|
||||
|
||||
@ -58,9 +58,9 @@ yii = (function ($) {
|
||||
changeableSelector: 'select, input, textarea',
|
||||
|
||||
/**
|
||||
* @return string|undefined the CSRF variable name. Undefined is returned if CSRF validation is not enabled.
|
||||
* @return string|undefined the CSRF parameter name. Undefined is returned if CSRF validation is not enabled.
|
||||
*/
|
||||
getCsrfVar: function () {
|
||||
getCsrfParam: function () {
|
||||
return $('meta[name=csrf-param]').prop('content');
|
||||
},
|
||||
|
||||
@ -130,9 +130,9 @@ yii = (function ($) {
|
||||
if (!method.match(/(get|post)/i)) {
|
||||
$form.append('<input name="_method" value="' + method + '" type="hidden">');
|
||||
}
|
||||
var csrfVar = pub.getCsrfVar();
|
||||
if (csrfVar) {
|
||||
$form.append('<input name="' + csrfVar + '" value="' + pub.getCsrfToken() + '" type="hidden">');
|
||||
var csrfParam = pub.getCsrfParam();
|
||||
if (csrfParam) {
|
||||
$form.append('<input name="' + csrfParam + '" value="' + pub.getCsrfToken() + '" type="hidden">');
|
||||
}
|
||||
$form.hide().appendTo('body');
|
||||
}
|
||||
@ -199,7 +199,7 @@ yii = (function ($) {
|
||||
function initCsrfHandler() {
|
||||
// automatically send CSRF token for all AJAX requests
|
||||
$.ajaxPrefilter(function (options, originalOptions, xhr) {
|
||||
if (!options.crossDomain && pub.getCsrfVar()) {
|
||||
if (!options.crossDomain && pub.getCsrfParam()) {
|
||||
xhr.setRequestHeader('X-CSRF-Token', pub.getCsrfToken());
|
||||
}
|
||||
});
|
||||
|
||||
@ -187,7 +187,7 @@ abstract class BaseDataProvider extends Component implements DataProviderInterfa
|
||||
if (is_array($value)) {
|
||||
$config = ['class' => Pagination::className()];
|
||||
if ($this->id !== null) {
|
||||
$config['pageVar'] = $this->id . '-page';
|
||||
$config['pageParam'] = $this->id . '-page';
|
||||
}
|
||||
$this->_pagination = Yii::createObject(array_merge($config, $value));
|
||||
} elseif ($value instanceof Pagination || $value === false) {
|
||||
@ -225,7 +225,7 @@ abstract class BaseDataProvider extends Component implements DataProviderInterfa
|
||||
if (is_array($value)) {
|
||||
$config = ['class' => Sort::className()];
|
||||
if ($this->id !== null) {
|
||||
$config['sortVar'] = $this->id . '-sort';
|
||||
$config['sortParam'] = $this->id . '-sort';
|
||||
}
|
||||
$this->_sort = Yii::createObject(array_merge($config, $value));
|
||||
} elseif ($value instanceof Sort || $value === false) {
|
||||
|
||||
@ -71,12 +71,12 @@ class Pagination extends Object
|
||||
* @var string name of the parameter storing the current page index. Defaults to 'page'.
|
||||
* @see params
|
||||
*/
|
||||
public $pageVar = 'page';
|
||||
public $pageParam = 'page';
|
||||
/**
|
||||
* @var boolean whether to always have the page parameter in the URL created by [[createUrl()]].
|
||||
* If false and [[page]] is 0, the page parameter will not be put in the URL.
|
||||
*/
|
||||
public $forcePageVar = true;
|
||||
public $forcePageParam = true;
|
||||
/**
|
||||
* @var string the route of the controller action for displaying the paged contents.
|
||||
* If not set, it means using the currently requested route.
|
||||
@ -88,7 +88,7 @@ class Pagination extends Object
|
||||
*
|
||||
* In order to add hash to all links use `array_merge($_GET, ['#' => 'my-hash'])`.
|
||||
*
|
||||
* The array element indexed by [[pageVar]] is considered to be the current page number.
|
||||
* The array element indexed by [[pageParam]] is considered to be the current page number.
|
||||
* If the element does not exist, the current page number is considered 0.
|
||||
*/
|
||||
public $params;
|
||||
@ -102,7 +102,7 @@ class Pagination extends Object
|
||||
* When this property is true, the value of [[page]] will always be between 0 and ([[pageCount]]-1).
|
||||
* Because [[pageCount]] relies on the correct value of [[totalCount]] which may not be available
|
||||
* in some cases (e.g. MongoDB), you may want to set this property to be false to disable the page
|
||||
* number validation. By doing so, [[page]] will return the value indexed by [[pageVar]] in [[params]].
|
||||
* number validation. By doing so, [[page]] will return the value indexed by [[pageParam]] in [[params]].
|
||||
*/
|
||||
public $validatePage = true;
|
||||
/**
|
||||
@ -143,8 +143,8 @@ class Pagination extends Object
|
||||
$request = Yii::$app->getRequest();
|
||||
$params = $request instanceof Request ? $request->getQueryParams() : [];
|
||||
}
|
||||
if (isset($params[$this->pageVar]) && is_scalar($params[$this->pageVar])) {
|
||||
$this->_page = (int)$params[$this->pageVar] - 1;
|
||||
if (isset($params[$this->pageParam]) && is_scalar($params[$this->pageParam])) {
|
||||
$this->_page = (int)$params[$this->pageParam] - 1;
|
||||
if ($this->validatePage) {
|
||||
$pageCount = $this->getPageCount();
|
||||
if ($this->_page >= $pageCount) {
|
||||
@ -177,7 +177,7 @@ class Pagination extends Object
|
||||
* @param boolean $absolute whether to create an absolute URL. Defaults to `false`.
|
||||
* @return string the created URL
|
||||
* @see params
|
||||
* @see forcePageVar
|
||||
* @see forcePageParam
|
||||
*/
|
||||
public function createUrl($page, $absolute = false)
|
||||
{
|
||||
@ -185,10 +185,10 @@ class Pagination extends Object
|
||||
$request = Yii::$app->getRequest();
|
||||
$params = $request instanceof Request ? $request->getQueryParams() : [];
|
||||
}
|
||||
if ($page > 0 || $page >= 0 && $this->forcePageVar) {
|
||||
$params[$this->pageVar] = $page + 1;
|
||||
if ($page > 0 || $page >= 0 && $this->forcePageParam) {
|
||||
$params[$this->pageParam] = $page + 1;
|
||||
} else {
|
||||
unset($params[$this->pageVar]);
|
||||
unset($params[$this->pageParam]);
|
||||
}
|
||||
$route = $this->route === null ? Yii::$app->controller->getRoute() : $this->route;
|
||||
$urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager;
|
||||
|
||||
@ -132,7 +132,7 @@ class Sort extends Object
|
||||
* in which direction. Defaults to 'sort'.
|
||||
* @see params
|
||||
*/
|
||||
public $sortVar = 'sort';
|
||||
public $sortParam = 'sort';
|
||||
/**
|
||||
* @var array the order that should be used when the current request does not specify any order.
|
||||
* The array keys are attribute names and the array values are the corresponding sort directions. For example,
|
||||
@ -162,10 +162,10 @@ class Sort extends Object
|
||||
*
|
||||
* In order to add hash to all links use `array_merge($_GET, ['#' => 'my-hash'])`.
|
||||
*
|
||||
* The array element indexed by [[sortVar]] is considered to be the current sort directions.
|
||||
* The array element indexed by [[sortParam]] is considered to be the current sort directions.
|
||||
* If the element does not exist, the [[defaultOrder|default order]] will be used.
|
||||
*
|
||||
* @see sortVar
|
||||
* @see sortParam
|
||||
* @see defaultOrder
|
||||
*/
|
||||
public $params;
|
||||
@ -239,8 +239,8 @@ class Sort extends Object
|
||||
$request = Yii::$app->getRequest();
|
||||
$params = $request instanceof Request ? $request->getQueryParams() : [];
|
||||
}
|
||||
if (isset($params[$this->sortVar]) && is_scalar($params[$this->sortVar])) {
|
||||
$attributes = explode($this->separator, $params[$this->sortVar]);
|
||||
if (isset($params[$this->sortParam]) && is_scalar($params[$this->sortParam])) {
|
||||
$attributes = explode($this->separator, $params[$this->sortParam]);
|
||||
foreach ($attributes as $attribute) {
|
||||
$descending = false;
|
||||
if (strncmp($attribute, '-', 1) === 0) {
|
||||
@ -301,7 +301,7 @@ class Sort extends Object
|
||||
}
|
||||
|
||||
$url = $this->createUrl($attribute);
|
||||
$options['data-sort'] = $this->createSortVar($attribute);
|
||||
$options['data-sort'] = $this->createSortParam($attribute);
|
||||
|
||||
if (isset($options['label'])) {
|
||||
$label = $options['label'];
|
||||
@ -334,7 +334,7 @@ class Sort extends Object
|
||||
$request = Yii::$app->getRequest();
|
||||
$params = $request instanceof Request ? $request->getQueryParams() : [];
|
||||
}
|
||||
$params[$this->sortVar] = $this->createSortVar($attribute);
|
||||
$params[$this->sortParam] = $this->createSortParam($attribute);
|
||||
$route = $this->route === null ? Yii::$app->controller->getRoute() : $this->route;
|
||||
$urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager;
|
||||
if ($absolute) {
|
||||
@ -352,7 +352,7 @@ class Sort extends Object
|
||||
* @return string the value of the sort variable
|
||||
* @throws InvalidConfigException if the specified attribute is not defined in [[attributes]]
|
||||
*/
|
||||
public function createSortVar($attribute)
|
||||
public function createSortParam($attribute)
|
||||
{
|
||||
if (!isset($this->attributes[$attribute])) {
|
||||
throw new InvalidConfigException("Unknown attribute: $attribute");
|
||||
|
||||
@ -223,7 +223,7 @@ class BaseHtml
|
||||
* @param string $method the form submission method, such as "post", "get", "put", "delete" (case-insensitive).
|
||||
* Since most browsers only support "post" and "get", if other methods are given, they will
|
||||
* be simulated using "post", and a hidden input will be added which contains the actual method type.
|
||||
* See [[\yii\web\Request::methodVar]] for more details.
|
||||
* See [[\yii\web\Request::methodParam]] for more details.
|
||||
* @param array $options the tag options in terms of name-value pairs. These will be rendered as
|
||||
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
|
||||
* If a value is null, the corresponding attribute will not be rendered.
|
||||
@ -240,11 +240,11 @@ class BaseHtml
|
||||
if ($request instanceof Request) {
|
||||
if (strcasecmp($method, 'get') && strcasecmp($method, 'post')) {
|
||||
// simulate PUT, DELETE, etc. via POST
|
||||
$hiddenInputs[] = static::hiddenInput($request->methodVar, $method);
|
||||
$hiddenInputs[] = static::hiddenInput($request->methodParam, $method);
|
||||
$method = 'post';
|
||||
}
|
||||
if ($request->enableCsrfValidation && !strcasecmp($method, 'post')) {
|
||||
$hiddenInputs[] = static::hiddenInput($request->csrfVar, $request->getCsrfToken());
|
||||
$hiddenInputs[] = static::hiddenInput($request->csrfParam, $request->getCsrfToken());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -94,10 +94,10 @@ class Request extends \yii\base\Request
|
||||
* from the same application. If not, a 400 HTTP exception will be raised.
|
||||
*
|
||||
* Note, this feature requires that the user client accepts cookie. Also, to use this feature,
|
||||
* forms submitted via POST method must contain a hidden input whose name is specified by [[csrfVar]].
|
||||
* forms submitted via POST method must contain a hidden input whose name is specified by [[csrfParam]].
|
||||
* You may use [[\yii\web\Html::beginForm()]] to generate his hidden input.
|
||||
*
|
||||
* In JavaScript, you may get the values of [[csrfVar]] and [[csrfToken]] via `yii.getCsrfParam()` and
|
||||
* In JavaScript, you may get the values of [[csrfParam]] and [[csrfToken]] via `yii.getCsrfParam()` and
|
||||
* `yii.getCsrfToken()`, respectively. The [[\yii\web\YiiAsset]] asset must be registered.
|
||||
*
|
||||
* @see Controller::enableCsrfValidation
|
||||
@ -108,7 +108,7 @@ class Request extends \yii\base\Request
|
||||
* @var string the name of the token used to prevent CSRF. Defaults to '_csrf'.
|
||||
* This property is used only when [[enableCsrfValidation]] is true.
|
||||
*/
|
||||
public $csrfVar = '_csrf';
|
||||
public $csrfParam = '_csrf';
|
||||
/**
|
||||
* @var array the configuration of the CSRF cookie. This property is used only when [[enableCsrfValidation]] is true.
|
||||
* @see Cookie
|
||||
@ -124,7 +124,7 @@ class Request extends \yii\base\Request
|
||||
* @see getMethod()
|
||||
* @see getBodyParams()
|
||||
*/
|
||||
public $methodVar = '_method';
|
||||
public $methodParam = '_method';
|
||||
/**
|
||||
* @var array the parsers for converting the raw HTTP request body into [[bodyParams]].
|
||||
* The array keys are the request `Content-Types`, and the array values are the
|
||||
@ -207,8 +207,8 @@ class Request extends \yii\base\Request
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
if (isset($_POST[$this->methodVar])) {
|
||||
return strtoupper($_POST[$this->methodVar]);
|
||||
if (isset($_POST[$this->methodParam])) {
|
||||
return strtoupper($_POST[$this->methodParam]);
|
||||
} elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
|
||||
return strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
|
||||
} else {
|
||||
@ -330,9 +330,9 @@ class Request extends \yii\base\Request
|
||||
{
|
||||
if ($this->_bodyParams === null) {
|
||||
$contentType = $this->getContentType();
|
||||
if (isset($_POST[$this->methodVar])) {
|
||||
if (isset($_POST[$this->methodParam])) {
|
||||
$this->_bodyParams = $_POST;
|
||||
unset($this->_bodyParams[$this->methodVar]);
|
||||
unset($this->_bodyParams[$this->methodParam]);
|
||||
} elseif (isset($this->parsers[$contentType])) {
|
||||
$parser = Yii::createObject($this->parsers[$contentType]);
|
||||
if (!($parser instanceof RequestParserInterface)) {
|
||||
@ -1102,7 +1102,7 @@ class Request extends \yii\base\Request
|
||||
public function getRawCsrfToken()
|
||||
{
|
||||
if ($this->_csrfCookie === null) {
|
||||
$this->_csrfCookie = $this->getCookies()->get($this->csrfVar);
|
||||
$this->_csrfCookie = $this->getCookies()->get($this->csrfParam);
|
||||
if ($this->_csrfCookie === null) {
|
||||
$this->_csrfCookie = $this->createCsrfCookie();
|
||||
Yii::$app->getResponse()->getCookies()->add($this->_csrfCookie);
|
||||
@ -1174,7 +1174,7 @@ class Request extends \yii\base\Request
|
||||
protected function createCsrfCookie()
|
||||
{
|
||||
$options = $this->csrfCookie;
|
||||
$options['name'] = $this->csrfVar;
|
||||
$options['name'] = $this->csrfParam;
|
||||
$options['value'] = Security::generateRandomKey();
|
||||
return new Cookie($options);
|
||||
}
|
||||
@ -1193,8 +1193,8 @@ class Request extends \yii\base\Request
|
||||
if (!$this->enableCsrfValidation || in_array($method, ['GET', 'HEAD', 'OPTIONS'], true)) {
|
||||
return true;
|
||||
}
|
||||
$trueToken = $this->getCookies()->getValue($this->csrfVar);
|
||||
$token = $this->getBodyParam($this->csrfVar);
|
||||
$trueToken = $this->getCookies()->getValue($this->csrfParam);
|
||||
$token = $this->getBodyParam($this->csrfParam);
|
||||
return $this->validateCsrfTokenInternal($token, $trueToken)
|
||||
|| $this->validateCsrfTokenInternal($this->getCsrfTokenFromHeader(), $trueToken);
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
/**
|
||||
* @var string the name of the session variable that stores the flash message data.
|
||||
*/
|
||||
public $flashVar = '__flash';
|
||||
public $flashParam = '__flash';
|
||||
/**
|
||||
* @var \SessionHandlerInterface|array an object implementing the SessionHandlerInterface or a configuration array. If set, will be used to provide persistency instead of build-in methods.
|
||||
*/
|
||||
@ -569,7 +569,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
*/
|
||||
protected function updateFlashCounters()
|
||||
{
|
||||
$counters = $this->get($this->flashVar, []);
|
||||
$counters = $this->get($this->flashParam, []);
|
||||
if (is_array($counters)) {
|
||||
foreach ($counters as $key => $count) {
|
||||
if ($count) {
|
||||
@ -578,10 +578,10 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
$counters[$key]++;
|
||||
}
|
||||
}
|
||||
$_SESSION[$this->flashVar] = $counters;
|
||||
$_SESSION[$this->flashParam] = $counters;
|
||||
} else {
|
||||
// fix the unexpected problem that flashVar doesn't return an array
|
||||
unset($_SESSION[$this->flashVar]);
|
||||
// fix the unexpected problem that flashParam doesn't return an array
|
||||
unset($_SESSION[$this->flashParam]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -596,7 +596,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
*/
|
||||
public function getFlash($key, $defaultValue = null, $delete = false)
|
||||
{
|
||||
$counters = $this->get($this->flashVar, []);
|
||||
$counters = $this->get($this->flashParam, []);
|
||||
if (isset($counters[$key])) {
|
||||
$value = $this->get($key, $defaultValue);
|
||||
if ($delete) {
|
||||
@ -614,7 +614,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
*/
|
||||
public function getAllFlashes()
|
||||
{
|
||||
$counters = $this->get($this->flashVar, []);
|
||||
$counters = $this->get($this->flashParam, []);
|
||||
$flashes = [];
|
||||
foreach (array_keys($counters) as $key) {
|
||||
if (isset($_SESSION[$key])) {
|
||||
@ -634,10 +634,10 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
*/
|
||||
public function setFlash($key, $value = true)
|
||||
{
|
||||
$counters = $this->get($this->flashVar, []);
|
||||
$counters = $this->get($this->flashParam, []);
|
||||
$counters[$key] = 0;
|
||||
$_SESSION[$key] = $value;
|
||||
$_SESSION[$this->flashVar] = $counters;
|
||||
$_SESSION[$this->flashParam] = $counters;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -650,10 +650,10 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
*/
|
||||
public function removeFlash($key)
|
||||
{
|
||||
$counters = $this->get($this->flashVar, []);
|
||||
$counters = $this->get($this->flashParam, []);
|
||||
$value = isset($_SESSION[$key], $counters[$key]) ? $_SESSION[$key] : null;
|
||||
unset($counters[$key], $_SESSION[$key]);
|
||||
$_SESSION[$this->flashVar] = $counters;
|
||||
$_SESSION[$this->flashParam] = $counters;
|
||||
return $value;
|
||||
}
|
||||
|
||||
@ -665,11 +665,11 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
*/
|
||||
public function removeAllFlashes()
|
||||
{
|
||||
$counters = $this->get($this->flashVar, []);
|
||||
$counters = $this->get($this->flashParam, []);
|
||||
foreach (array_keys($counters) as $key) {
|
||||
unset($_SESSION[$key]);
|
||||
}
|
||||
unset($_SESSION[$this->flashVar]);
|
||||
unset($_SESSION[$this->flashParam]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -105,9 +105,9 @@ class UrlManager extends Component
|
||||
*/
|
||||
public $showScriptName = true;
|
||||
/**
|
||||
* @var string the GET variable name for route. This property is used only if [[enablePrettyUrl]] is false.
|
||||
* @var string the GET parameter name for route. This property is used only if [[enablePrettyUrl]] is false.
|
||||
*/
|
||||
public $routeVar = 'r';
|
||||
public $routeParam = 'r';
|
||||
/**
|
||||
* @var Cache|string the cache object or the application component ID of the cache object.
|
||||
* Compiled URL rules will be cached through this cache object, if it is available.
|
||||
@ -217,7 +217,7 @@ class UrlManager extends Component
|
||||
return [$pathInfo, []];
|
||||
} else {
|
||||
Yii::trace('Pretty URL not enabled. Using default URL parsing logic.', __METHOD__);
|
||||
$route = $request->getQueryParam($this->routeVar, '');
|
||||
$route = $request->getQueryParam($this->routeParam, '');
|
||||
if (is_array($route)) {
|
||||
$route = '';
|
||||
}
|
||||
@ -235,7 +235,7 @@ class UrlManager extends Component
|
||||
public function createUrl($route, $params = [])
|
||||
{
|
||||
$anchor = isset($params['#']) ? '#' . $params['#'] : '';
|
||||
unset($params['#'], $params[$this->routeVar]);
|
||||
unset($params['#'], $params[$this->routeParam]);
|
||||
|
||||
$route = trim($route, '/');
|
||||
$baseUrl = $this->getBaseUrl();
|
||||
@ -264,7 +264,7 @@ class UrlManager extends Component
|
||||
}
|
||||
return "$baseUrl/{$route}{$anchor}";
|
||||
} else {
|
||||
$url = "$baseUrl?{$this->routeVar}=$route";
|
||||
$url = "$baseUrl?{$this->routeParam}=$route";
|
||||
if (!empty($params)) {
|
||||
$url .= '&' . http_build_query($params);
|
||||
}
|
||||
|
||||
@ -97,16 +97,16 @@ class User extends Component
|
||||
/**
|
||||
* @var string the session variable name used to store the value of [[id]].
|
||||
*/
|
||||
public $idVar = '__id';
|
||||
public $idParam = '__id';
|
||||
/**
|
||||
* @var string the session variable name used to store the value of expiration timestamp of the authenticated state.
|
||||
* This is used when [[authTimeout]] is set.
|
||||
*/
|
||||
public $authTimeoutVar = '__expire';
|
||||
public $authTimeoutParam = '__expire';
|
||||
/**
|
||||
* @var string the session variable name used to store the value of [[returnUrl]].
|
||||
*/
|
||||
public $returnUrlVar = '__returnUrl';
|
||||
public $returnUrlParam = '__returnUrl';
|
||||
|
||||
private $_access = [];
|
||||
|
||||
@ -270,7 +270,7 @@ class User extends Component
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return Yii::$app->getSession()->get($this->idVar);
|
||||
return Yii::$app->getSession()->get($this->idParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -285,7 +285,7 @@ class User extends Component
|
||||
*/
|
||||
public function getReturnUrl($defaultUrl = null)
|
||||
{
|
||||
$url = Yii::$app->getSession()->get($this->returnUrlVar, $defaultUrl);
|
||||
$url = Yii::$app->getSession()->get($this->returnUrlParam, $defaultUrl);
|
||||
if (is_array($url)) {
|
||||
if (isset($url[0])) {
|
||||
$route = array_shift($url);
|
||||
@ -309,7 +309,7 @@ class User extends Component
|
||||
*/
|
||||
public function setReturnUrl($url)
|
||||
{
|
||||
Yii::$app->getSession()->set($this->returnUrlVar, $url);
|
||||
Yii::$app->getSession()->set($this->returnUrlParam, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -467,12 +467,12 @@ class User extends Component
|
||||
$session->regenerateID(true);
|
||||
}
|
||||
$this->setIdentity($identity);
|
||||
$session->remove($this->idVar);
|
||||
$session->remove($this->authTimeoutVar);
|
||||
$session->remove($this->idParam);
|
||||
$session->remove($this->authTimeoutParam);
|
||||
if ($identity instanceof IdentityInterface) {
|
||||
$session->set($this->idVar, $identity->getId());
|
||||
$session->set($this->idParam, $identity->getId());
|
||||
if ($this->authTimeout !== null) {
|
||||
$session->set($this->authTimeoutVar, time() + $this->authTimeout);
|
||||
$session->set($this->authTimeoutParam, time() + $this->authTimeout);
|
||||
}
|
||||
if ($duration > 0 && $this->enableAutoLogin) {
|
||||
$this->sendIdentityCookie($identity, $duration);
|
||||
@ -491,11 +491,11 @@ class User extends Component
|
||||
protected function renewAuthStatus()
|
||||
{
|
||||
if ($this->authTimeout !== null && !$this->getIsGuest()) {
|
||||
$expire = Yii::$app->getSession()->get($this->authTimeoutVar);
|
||||
$expire = Yii::$app->getSession()->get($this->authTimeoutParam);
|
||||
if ($expire !== null && $expire < time()) {
|
||||
$this->logout(false);
|
||||
} else {
|
||||
Yii::$app->getSession()->set($this->authTimeoutVar, time() + $this->authTimeout);
|
||||
Yii::$app->getSession()->set($this->authTimeoutParam, time() + $this->authTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -457,7 +457,7 @@ class View extends \yii\base\View
|
||||
|
||||
$request = Yii::$app->getRequest();
|
||||
if ($request instanceof \yii\web\Request && $request->enableCsrfValidation && !$request->getIsAjax()) {
|
||||
$lines[] = Html::tag('meta', '', ['name' => 'csrf-param', 'content' => $request->csrfVar]);
|
||||
$lines[] = Html::tag('meta', '', ['name' => 'csrf-param', 'content' => $request->csrfParam]);
|
||||
$lines[] = Html::tag('meta', '', ['name' => 'csrf-token', 'content' => $request->getCsrfToken()]);
|
||||
}
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ class ActiveForm extends Widget
|
||||
/**
|
||||
* @var string the name of the GET parameter indicating the validation request is an AJAX request.
|
||||
*/
|
||||
public $ajaxVar = 'ajax';
|
||||
public $ajaxParam = 'ajax';
|
||||
/**
|
||||
* @var string the type of data that you're expecting back from the server.
|
||||
*/
|
||||
@ -190,7 +190,7 @@ class ActiveForm extends Widget
|
||||
'errorCssClass' => $this->errorCssClass,
|
||||
'successCssClass' => $this->successCssClass,
|
||||
'validatingCssClass' => $this->validatingCssClass,
|
||||
'ajaxVar' => $this->ajaxVar,
|
||||
'ajaxParam' => $this->ajaxParam,
|
||||
'ajaxDataType' => $this->ajaxDataType,
|
||||
];
|
||||
if ($this->validationUrl !== null) {
|
||||
|
||||
@ -101,7 +101,7 @@ class SortTest extends TestCase
|
||||
$this->assertNull($sort->getAttributeOrder('xyz'));
|
||||
}
|
||||
|
||||
public function testCreateSortVar()
|
||||
public function testCreateSortParam()
|
||||
{
|
||||
$sort = new Sort([
|
||||
'attributes' => [
|
||||
@ -118,8 +118,8 @@ class SortTest extends TestCase
|
||||
'route' => 'site/index',
|
||||
]);
|
||||
|
||||
$this->assertEquals('-age,-name', $sort->createSortVar('age'));
|
||||
$this->assertEquals('name,age', $sort->createSortVar('name'));
|
||||
$this->assertEquals('-age,-name', $sort->createSortParam('age'));
|
||||
$this->assertEquals('name,age', $sort->createSortParam('name'));
|
||||
}
|
||||
|
||||
public function testCreateUrl()
|
||||
|
||||
Reference in New Issue
Block a user