From 53e193049f7cb52e035737fa45c46f738a73a040 Mon Sep 17 00:00:00 2001 From: MDMunir Date: Thu, 22 May 2014 17:57:30 +0700 Subject: [PATCH 1/4] Add $key to function parameter I think it's better to enclose `$key` as function parameter. --- framework/grid/DataColumn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/grid/DataColumn.php b/framework/grid/DataColumn.php index b1a79b0041..5263189b74 100644 --- a/framework/grid/DataColumn.php +++ b/framework/grid/DataColumn.php @@ -51,7 +51,7 @@ class DataColumn extends Column public $label; /** * @var string|\Closure an anonymous function that returns the value to be displayed for every data model. - * The signature of this function is `function ($model, $index, $widget)`. + * The signature of this function is `function ($model, $key, $index, $widget)`. * If this is not set, `$model[$attribute]` will be used to obtain the value. * * You may also set this property to a string representing the attribute name to be displayed in this column. @@ -176,7 +176,7 @@ class DataColumn extends Column if (is_string($this->value)) { return ArrayHelper::getValue($model, $this->value); } else { - return call_user_func($this->value, $model, $index, $this); + return call_user_func($this->value, $model, $key, $index, $this); } } elseif ($this->attribute !== null) { return ArrayHelper::getValue($model, $this->attribute); From f55a59a2b946c52e0e871370c1d38e1d0604dfd7 Mon Sep 17 00:00:00 2001 From: MDMunir Date: Thu, 22 May 2014 20:55:58 +0700 Subject: [PATCH 2/4] Update CHANGELOG.md --- framework/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 9f0519a1d8..b40a5c58fe 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -71,6 +71,7 @@ Yii Framework 2 Change Log - Chg: `yii\data\ActiveDataProvider::$query` will not be modified directly with pagination and sorting anymore so it will be reuseable (cebe) - Chg: Removed `yii\rest\ActiveController::$transactional` property and connected functionality (samdark) - Chg: Changed the default value of the `keyPrefix` property of cache components to be null (qiangxue) +- Chg #3544: Add `$key` to function parameter `yii\grid\DataColumn::value` (mdmunir) 2.0.0-beta April 13, 2014 ------------------------- From 8f8ec23d52427efdbbc486a617d04b5dda18f133 Mon Sep 17 00:00:00 2001 From: MDMunir Date: Thu, 22 May 2014 21:15:44 +0700 Subject: [PATCH 3/4] Log for pull request #3544 --- framework/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index b40a5c58fe..223bf62984 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -71,7 +71,7 @@ Yii Framework 2 Change Log - Chg: `yii\data\ActiveDataProvider::$query` will not be modified directly with pagination and sorting anymore so it will be reuseable (cebe) - Chg: Removed `yii\rest\ActiveController::$transactional` property and connected functionality (samdark) - Chg: Changed the default value of the `keyPrefix` property of cache components to be null (qiangxue) -- Chg #3544: Add `$key` to function parameter `yii\grid\DataColumn::value` (mdmunir) +- Chg #3544: Added `$key` as parameter of `yii\grid\DataColumn::value` (mdmunir) 2.0.0-beta April 13, 2014 ------------------------- From 50c6b690dddaddee7052d1a17f7131b8705aaf97 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 24 May 2014 09:12:39 -0400 Subject: [PATCH 4/4] updated upgrade info [skip ci] --- framework/CHANGELOG.md | 2 +- framework/UPGRADE.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 482baa1908..8be556d19c 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -71,13 +71,13 @@ Yii Framework 2 Change Log - Chg #3175: InvalidCallException, InvalidParamException, UnknownMethodException are now extended from SPL BadMethodCallException (samdark) - Chg #3383: Added `$type` parameter to `IdentityInterface::findIdentityByAccessToken()` (qiangxue) - Chg #3531: \yii\grid\GridView now allows any character (except ":") in the attribute part of the shorthand syntax for columns (rawtaz) +- Chg #3544: Added `$key` as a parameter to the callable specified via `yii\grid\DataColumn::value` (mdmunir) - Chg: Replaced `clearAll()` and `clearAllAssignments()` in `yii\rbac\ManagerInterface` with `removeAll()`, `removeAllRoles()`, `removeAllPermissions()`, `removeAllRules()` and `removeAllAssignments()` (qiangxue) - Chg: Added `$user` as the first parameter of `yii\rbac\Rule::execute()` (qiangxue) - Chg: `yii\grid\DataColumn::getDataCellValue()` visibility is now `public` to allow accessing the value from a GridView directly (cebe) - Chg: `yii\data\ActiveDataProvider::$query` will not be modified directly with pagination and sorting anymore so it will be reuseable (cebe) - Chg: Removed `yii\rest\ActiveController::$transactional` property and connected functionality (samdark) - Chg: Changed the default value of the `keyPrefix` property of cache components to be null (qiangxue) -- Chg #3544: Added `$key` as parameter of `yii\grid\DataColumn::value` (mdmunir) 2.0.0-beta April 13, 2014 ------------------------- diff --git a/framework/UPGRADE.md b/framework/UPGRADE.md index 21d8939252..110dff5ede 100644 --- a/framework/UPGRADE.md +++ b/framework/UPGRADE.md @@ -37,3 +37,8 @@ Upgrade from Yii 2.0 Beta * If you are using `dropDownList()`, `listBox()`, `activeDropDownList()`, or `activeListBox()` of `yii\helpers\Html`, and your list options use multiple blank spaces to format and align option label texts, you need to specify the option `encodeSpaces` to be true. + +* If you are using `yii\grid\GridView` and have configured a data column to use a PHP callable + to return cell values (via `yii\grid\DataColumn::value`), you may need to adjust the signature + of the callable to be `function ($model, $key, $index, $widget)`. The `$key` parameter was newly added + in this release.