{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/11951","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/11951/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/11951/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/11951/events","html_url":"https://github.com/yiisoft/yii2/issues/11951","id":165473114,"number":11951,"title":"Yii2 RESTful custom response is being ignored","user":{"login":"kynamar","id":18315614,"avatar_url":"https://avatars.githubusercontent.com/u/18315614?v=3","gravatar_id":"","url":"https://api.github.com/users/kynamar","html_url":"https://github.com/kynamar","followers_url":"https://api.github.com/users/kynamar/followers","following_url":"https://api.github.com/users/kynamar/following{/other_user}","gists_url":"https://api.github.com/users/kynamar/gists{/gist_id}","starred_url":"https://api.github.com/users/kynamar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kynamar/subscriptions","organizations_url":"https://api.github.com/users/kynamar/orgs","repos_url":"https://api.github.com/users/kynamar/repos","events_url":"https://api.github.com/users/kynamar/events{/privacy}","received_events_url":"https://api.github.com/users/kynamar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/status:need%20more%20info","name":"status:need more info","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-14T04:23:58Z","updated_at":"2016-07-14T10:09:59Z","closed_at":"2016-07-14T10:09:59Z","body":"## What steps will reproduce the problem?\r\nI am trying to use the following custom response in my main.php config file(api folder)\r\n\r\n```php\r\n 'response' => [\r\n            'class' => 'yii\\web\\Response',\r\n            'on beforeSend' => function ($event) {\r\n                $response = $event->sender;\r\n                if ($response->data !== null && Yii::$app->request->get('suppress_response_code')) {\r\n                    $response->data = [\r\n                        'success' => $response->isSuccessful,\r\n                        'data' => $response->data,\r\n                    ];\r\n                    $response->statusCode = 200;\r\n                }\r\n            },\r\n                ],\r\n```\r\n\r\n### What is the expected result?\r\nWhen I access http://localhost/MyProject/api/web/v1/colors?per-page=2, instead of \r\n\r\n```json\r\n{ status:true, data:[{\"id\":1,\"color_name\":\"Red\",\"color_code\":\"#FF0000\",\"active\":1},{\"id\":2,\"color_name\":\"White\",\"color_code\":\"#FFFFFF\",\"active\":1}]} \r\n```\r\n\r\nI get only\r\n```json\r\n[{\"id\":1,\"color_name\":\"Red\",\"color_code\":\"#FF0000\",\"active\":1},{\"id\":2,\"color_name\":\"White\",\"color_code\":\"#FFFFFF\",\"active\":1}]\r\n```\r\n\r\n\r\nWhat could cause this problem ?\r\nThank you in advance.\r\n\r\n### Additional info\r\n\r\n| Q                | A\r\n| ---------------- | ---\r\n| Yii version      |   2.0.8\r\n| PHP version      |   5.5.12\r\n| Operating system | \r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/232623554","html_url":"https://github.com/yiisoft/yii2/issues/11951#issuecomment-232623554","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/11951","id":232623554,"user":{"login":"samdark","id":47294,"avatar_url":"https://avatars.githubusercontent.com/u/47294?v=3","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"created_at":"2016-07-14T10:09:59Z","updated_at":"2016-07-14T10:09:59Z","body":"Well, you don't have `suppress_response_code` in your GET so it's expected that code in `on beforeSend` isn't reached."}}
{"actor":{"display_login":"samdark"}}