{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8635","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8635/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8635/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8635/events","html_url":"https://github.com/yiisoft/yii2/issues/8635","id":83965649,"number":8635,"title":"Add support for verbs to create url.","user":{"login":"SamMousa","id":547021,"avatar_url":"https://avatars.githubusercontent.com/u/547021?v=3","gravatar_id":"","url":"https://api.github.com/users/SamMousa","html_url":"https://github.com/SamMousa","followers_url":"https://api.github.com/users/SamMousa/followers","following_url":"https://api.github.com/users/SamMousa/following{/other_user}","gists_url":"https://api.github.com/users/SamMousa/gists{/gist_id}","starred_url":"https://api.github.com/users/SamMousa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamMousa/subscriptions","organizations_url":"https://api.github.com/users/SamMousa/orgs","repos_url":"https://api.github.com/users/SamMousa/repos","events_url":"https://api.github.com/users/SamMousa/events{/privacy}","received_events_url":"https://api.github.com/users/SamMousa/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/feature:rest","name":"feature:rest","color":"bfd4f2"},{"url":"https://api.github.com/repos/yiisoft/yii2/labels/status:under%20discussion","name":"status:under discussion","color":"f7c6c7"}],"state":"open","locked":false,"assignee":{"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},"assignees":[{"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}],"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/9","html_url":"https://github.com/yiisoft/yii2/milestones/2.0.x","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/9/labels","id":831720,"number":9,"title":"2.0.x","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":400,"closed_issues":2,"state":"open","created_at":"2014-10-19T13:49:45Z","updated_at":"2016-09-21T07:07:24Z","due_on":null,"closed_at":null},"comments":32,"created_at":"2015-06-02T10:47:15Z","updated_at":"2016-09-22T11:39:36Z","closed_at":null,"body":"Currently when creating URLs via the Url helper or UrlManager, the intended verb is not used.\r\n\r\nIt should be possible to add an optional parameter to the URL creation routines. This would then be passed on to CUrlRule::createUrl, which will return false if the rule does not apply to the passed VERB.\r\n\r\nSuppose you have URL rules that do this:\r\nput to /cars/18  ---> CarsController::actionUpdate(18);\r\nget to /cars/18 ---> CarsController::actionRead(18)\r\n\r\nNow for some page I need to make a put request to the read action; this is impossible using the url generator functions.\r\n\r\nUrl::to(['cars/read', 'id' => 18) will create /cars/18, which will resolve to update if i do a put request.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/248879529","html_url":"https://github.com/yiisoft/yii2/issues/8635#issuecomment-248879529","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/8635","id":248879529,"user":{"login":"SamMousa","id":547021,"avatar_url":"https://avatars.githubusercontent.com/u/547021?v=3","gravatar_id":"","url":"https://api.github.com/users/SamMousa","html_url":"https://github.com/SamMousa","followers_url":"https://api.github.com/users/SamMousa/followers","following_url":"https://api.github.com/users/SamMousa/following{/other_user}","gists_url":"https://api.github.com/users/SamMousa/gists{/gist_id}","starred_url":"https://api.github.com/users/SamMousa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamMousa/subscriptions","organizations_url":"https://api.github.com/users/SamMousa/orgs","repos_url":"https://api.github.com/users/SamMousa/repos","events_url":"https://api.github.com/users/SamMousa/events{/privacy}","received_events_url":"https://api.github.com/users/SamMousa/received_events","type":"User","site_admin":false},"created_at":"2016-09-22T11:39:36Z","updated_at":"2016-09-22T11:39:36Z","body":"Okay, spent some more time on this. Currently I have a (partial) implementation:\r\nRules, strict parsing is enabled:\r\n````\r\n[\r\n        'verb' => 'GET',\r\n        'pattern' => '<controller:\\w+>/<id:\\d+>',\r\n        'route' => '<controller>/read'\r\n    ],\r\n    [\r\n        'verb' => 'PUT',\r\n        'pattern' => '<controller>/<id:\\d+>',\r\n        'route' => '<controller>/update',\r\n    ],\r\n    [\r\n        'verb' => 'POST',\r\n        'pattern' => '<controller>',\r\n        'route' => '<controller>/create',\r\n    ],\r\n\r\n    [\r\n        'verb' => 'DELETE',\r\n        'pattern' => '<controller>/<id:\\d+>',\r\n        'route' => '<controller>/delete'\r\n    ],\r\n\r\n````\r\n\r\nThis is the output, columns are (test case, route, params and result)\r\n````\r\n1  model/read          [id => 2]            --> /model/2\r\n2  model/read          [id => 2][b => test] --> /model/2?b=test\r\n3  model/update        [id => 2]            --> /model/2\r\n4  POST model/read     [id => 2]            --> /model/read?id=2\r\n5  PUT model/update    [id => 2]            --> /model/2\r\n6  GET model/read      [id => 3]            --> /model/3\r\n7  DELETE model/read   [id => 3]            --> /model/read?id=3\r\n8  DELETE model/delete [id => 3]            --> /model/3\r\n9  DELETE model        [id => 3]            --> /dev/model?id=3\r\n10 DELETE /model       [id => 3]            --> /model?id=3\r\n11 model/create        [test => 2]          --> /model?test=2\r\n12 GET model/create    [test => 2]          --> /model/create?test=2\r\n13 POST model/create   [test => 5]          --> /model?test=5\r\n14 model/update        [test => 2]          --> /model/update?test=2\r\n````\r\n\r\nThe only issue is the default configuration where there is no `verb` as part of the route. \r\nThis implementation does not \"assume\" anything, so in the case of `11` it will use the `POST` rule even though this might not be expected behavior.\r\n\r\nFeed back please!\r\n "}}
{"actor":{"display_login":"SamMousa"}}