diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 8b11150a1e..88e59bc27a 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -247,6 +247,7 @@ Yii Framework 2 Change Log - Chg #4586: Signed bigint and unsigned int will be converted into integers when they are loaded from DB by AR (qiangxue) - Chg #4591: `yii\helpers\Url::to()` will no longer prefix relative URLs with the base URL (qiangxue) - Chg #4595: `yii\widgets\LinkPager`'s `nextPageLabel`, `prevPageLabel`, `firstPageLabel`, `lastPageLabel` are now taking `false` instead of `null` for "no label" (samdark) +- Chg #4911: Changed callback signature used in `yii\base\ArrayableTrait::fields()` from `function ($field, $model) {` to `function ($model, $field) {` (samdark) - 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) diff --git a/framework/UPGRADE.md b/framework/UPGRADE.md index 8dd2259556..c977efe61f 100644 --- a/framework/UPGRADE.md +++ b/framework/UPGRADE.md @@ -206,3 +206,6 @@ new ones save the following code as `convert.php` that should be placed in the s - `sendContentAsFile($content, $attachmentName, $options = [])` - `sendStreamAsFile($handle, $attachmentName, $options = [])` - `xSendFile($filePath, $attachmentName = null, $options = [])` + +* The signature of callbacks used in `yii\base\ArrayableTrait::fields()` is changed from `function ($field, $model) {` + to `function ($model, $field) {`. diff --git a/framework/base/ArrayableTrait.php b/framework/base/ArrayableTrait.php index 4ce567965d..60f481ab4a 100644 --- a/framework/base/ArrayableTrait.php +++ b/framework/base/ArrayableTrait.php @@ -35,7 +35,7 @@ trait ArrayableTrait * returning the corresponding field value. The signature of the callable should be: * * ```php - * function ($field, $model) { + * function ($model, $field) { * // return field value * } * ``` @@ -118,7 +118,7 @@ trait ArrayableTrait { $data = []; foreach ($this->resolveFields($fields, $expand) as $field => $definition) { - $data[$field] = is_string($definition) ? $this->$definition : call_user_func($definition, $field, $this); + $data[$field] = is_string($definition) ? $this->$definition : call_user_func($definition, $this, $field); } if ($this instanceof Linkable) {