{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/12017","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/12017/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/12017/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/12017/events","html_url":"https://github.com/yiisoft/yii2/issues/12017","id":167466038,"number":12017,"title":"Add additional info to Yii2 assets guide ","user":{"login":"PowerGamer1","id":8275897,"avatar_url":"https://avatars.githubusercontent.com/u/8275897?v=3","gravatar_id":"","url":"https://api.github.com/users/PowerGamer1","html_url":"https://github.com/PowerGamer1","followers_url":"https://api.github.com/users/PowerGamer1/followers","following_url":"https://api.github.com/users/PowerGamer1/following{/other_user}","gists_url":"https://api.github.com/users/PowerGamer1/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerGamer1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerGamer1/subscriptions","organizations_url":"https://api.github.com/users/PowerGamer1/orgs","repos_url":"https://api.github.com/users/PowerGamer1/repos","events_url":"https://api.github.com/users/PowerGamer1/events{/privacy}","received_events_url":"https://api.github.com/users/PowerGamer1/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/type:docs","name":"type:docs","color":"207de5"}],"state":"closed","locked":false,"assignee":{"login":"klimov-paul","id":1482054,"avatar_url":"https://avatars.githubusercontent.com/u/1482054?v=3","gravatar_id":"","url":"https://api.github.com/users/klimov-paul","html_url":"https://github.com/klimov-paul","followers_url":"https://api.github.com/users/klimov-paul/followers","following_url":"https://api.github.com/users/klimov-paul/following{/other_user}","gists_url":"https://api.github.com/users/klimov-paul/gists{/gist_id}","starred_url":"https://api.github.com/users/klimov-paul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klimov-paul/subscriptions","organizations_url":"https://api.github.com/users/klimov-paul/orgs","repos_url":"https://api.github.com/users/klimov-paul/repos","events_url":"https://api.github.com/users/klimov-paul/events{/privacy}","received_events_url":"https://api.github.com/users/klimov-paul/received_events","type":"User","site_admin":false},"assignees":[{"login":"klimov-paul","id":1482054,"avatar_url":"https://avatars.githubusercontent.com/u/1482054?v=3","gravatar_id":"","url":"https://api.github.com/users/klimov-paul","html_url":"https://github.com/klimov-paul","followers_url":"https://api.github.com/users/klimov-paul/followers","following_url":"https://api.github.com/users/klimov-paul/following{/other_user}","gists_url":"https://api.github.com/users/klimov-paul/gists{/gist_id}","starred_url":"https://api.github.com/users/klimov-paul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klimov-paul/subscriptions","organizations_url":"https://api.github.com/users/klimov-paul/orgs","repos_url":"https://api.github.com/users/klimov-paul/repos","events_url":"https://api.github.com/users/klimov-paul/events{/privacy}","received_events_url":"https://api.github.com/users/klimov-paul/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/18","html_url":"https://github.com/yiisoft/yii2/milestones/2.0.10","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/18/labels","id":1679982,"number":18,"title":"2.0.10","description":"","creator":{"login":"cebe","id":189796,"avatar_url":"https://avatars.githubusercontent.com/u/189796?v=3","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"open_issues":69,"closed_issues":105,"state":"open","created_at":"2016-04-03T04:39:22Z","updated_at":"2016-09-01T13:50:54Z","due_on":"2016-09-10T22:00:00Z","closed_at":null},"comments":14,"created_at":"2016-07-25T21:07:19Z","updated_at":"2016-09-01T13:50:54Z","closed_at":"2016-09-01T13:50:54Z","body":"The guide http://www.yiiframework.com/doc-2.0/guide-structure-assets.html could benefit from covering the following topic: is it supported/recommended to modify `$js` / `$css` and `$jsOptions` / `$cssOptions` of already published assets bundle?\r\n\r\nExample: MyWidget can be configured to require 1.js OR 2.js. Some page may only use instances of MyWidget configured for 1.js, other page may only use instances of MyWidget configured for 2.js and yet another page may use several instances of MyWidget configured for 1.js and at the same time several instances of MyWidget configured for 2.js.\r\n\r\nSolution 1:\r\n```PHP\r\nclass MyWidgetAsset1 extends \\yii\\web\\AssetBundle\r\n{\r\n\tpublic $sourcePath = 'somepath';\r\n\tpublic $js = ['1.js'];\r\n}\r\nclass MyWidgetAsset2 extends \\yii\\web\\AssetBundle\r\n{\r\n\tpublic $sourcePath = 'somepath';\r\n\tpublic $js = ['2.js'];\r\n}\r\nclass MyWidget extends \\yii\\base\\Widget\r\n{\r\n\tpublic function run()\r\n\t{\r\n             if($this->config['type'] == 1)\r\n                    MyWidgetAsset1::register($this->getView());\r\n             else\r\n                    MyWidgetAsset2::register($this->getView());\r\n        }\r\n}\r\n```\r\n\r\nSolution 2: (needs confirmation if supported/recommended by Yii2):\r\n```PHP\r\nclass MyWidgetAsset extends \\yii\\web\\AssetBundle\r\n{\r\n\tpublic $sourcePath = 'somepath';\r\n\tpublic $js = [];\r\n}\r\nclass MyWidget extends \\yii\\base\\Widget\r\n{\r\n\tpublic function run()\r\n\t{\r\n             $bundle = MyWidgetAsset::register($this->getView());\r\n             if($this->config['type'] == 1 && !in_array('1.js', $bundle->js))\r\n                    $bundle->js[] = '1.js';\r\n             else if(!in_array('2.js', $bundle->js))\r\n                     $bundle->js[] = '2.js';\r\n       }\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/244084738","html_url":"https://github.com/yiisoft/yii2/issues/12017#issuecomment-244084738","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/12017","id":244084738,"user":{"login":"klimov-paul","id":1482054,"avatar_url":"https://avatars.githubusercontent.com/u/1482054?v=3","gravatar_id":"","url":"https://api.github.com/users/klimov-paul","html_url":"https://github.com/klimov-paul","followers_url":"https://api.github.com/users/klimov-paul/followers","following_url":"https://api.github.com/users/klimov-paul/following{/other_user}","gists_url":"https://api.github.com/users/klimov-paul/gists{/gist_id}","starred_url":"https://api.github.com/users/klimov-paul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klimov-paul/subscriptions","organizations_url":"https://api.github.com/users/klimov-paul/orgs","repos_url":"https://api.github.com/users/klimov-paul/repos","events_url":"https://api.github.com/users/klimov-paul/events{/privacy}","received_events_url":"https://api.github.com/users/klimov-paul/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T13:50:54Z","updated_at":"2016-09-01T13:50:54Z","body":"Resolved by commit 65c60a0c2477117d07a64f45af8fa6c58f3edf62"}}
{"actor":{"display_login":"klimov-paul"}}