{"action":"opened","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/12015","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/12015/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/12015/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/12015/events","html_url":"https://github.com/yiisoft/yii2/issues/12015","id":167455731,"number":12015,"title":"Feature Request: private to protected scope changes in ActiveQueryTrait","user":{"login":"ArekX","id":4344776,"avatar_url":"https://avatars.githubusercontent.com/u/4344776?v=3","gravatar_id":"","url":"https://api.github.com/users/ArekX","html_url":"https://github.com/ArekX","followers_url":"https://api.github.com/users/ArekX/followers","following_url":"https://api.github.com/users/ArekX/following{/other_user}","gists_url":"https://api.github.com/users/ArekX/gists{/gist_id}","starred_url":"https://api.github.com/users/ArekX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArekX/subscriptions","organizations_url":"https://api.github.com/users/ArekX/orgs","repos_url":"https://api.github.com/users/ArekX/repos","events_url":"https://api.github.com/users/ArekX/events{/privacy}","received_events_url":"https://api.github.com/users/ArekX/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-25T20:18:34Z","updated_at":"2016-07-25T20:18:34Z","closed_at":null,"body":"I know this might be a bit strange to ask, but I would like if it is possible to change private scope of `createModels` in `ActiveQueryTrait`. \r\n\r\nGenerally my opinion is that one should never use private scope inside frameworks since you never know which part of the framework somebody might use and modify by extending that class and overriding that function. It would be best to use only protected and public.\r\n\r\nHere is a reason why I would find this change to be really good:\r\nWe wanted to make a functionality which extends ActiveRecord query and allows you to do things like:\r\n```php\r\nActiveRecord::find()->configure([\r\n   'scenario' => 'some-scenario',\r\n   'attribute1' => '...'\r\n   // ...\r\n])->andWhere()->orWhere()->all();\r\n```\r\nWhich would basically return all models already set with attributes and scenarios of my choosing. You could argue that I could do this in `afterFind` of a specific model but this leaves way more customization ability because sometimes I want to avoid doing things (like loading additional data) in `afterFind` when a specific scenario is set and there is no way to do this in current Yii 2. If I could extend `createModels` function. Here is how it would look like in extended ActiveQuery:\r\n```php\r\nclass ActiveQueryExtension extends yii\\db\\ActiveQuery {\r\n    public $modelConfig = [];\r\n\r\n    public function configure($data)\r\n    {\r\n        $this->_modelConfig = $data;\r\n        return $this;\r\n    }\r\n\r\n    protected function createModels($rows) \r\n    {\r\n        $models = parent::createModels($rows);\r\n\r\n        foreach($models as $model) {\r\n              \\Yii::configure($model, $this->modelConfig);\r\n        }   \r\n\r\n        return $models;\r\n    }\r\n}\r\n```"}}
{"actor":{"display_login":"ArekX"}}