{"action":"created","issue":{"url":"https://api.github.com/repos/contao/core-bundle/issues/480","repository_url":"https://api.github.com/repos/contao/core-bundle","labels_url":"https://api.github.com/repos/contao/core-bundle/issues/480/labels{/name}","comments_url":"https://api.github.com/repos/contao/core-bundle/issues/480/comments","events_url":"https://api.github.com/repos/contao/core-bundle/issues/480/events","html_url":"https://github.com/contao/core-bundle/pull/480","id":153071637,"number":480,"title":"[RFC] Url generator","user":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/contao/core-bundle/labels/feature","name":"feature","color":"3364b7"}],"state":"open","locked":false,"assignee":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2016-05-04T17:34:06Z","updated_at":"2016-05-06T13:49:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/contao/core-bundle/pulls/480","html_url":"https://github.com/contao/core-bundle/pull/480","diff_url":"https://github.com/contao/core-bundle/pull/480.diff","patch_url":"https://github.com/contao/core-bundle/pull/480.patch"},"body":"Per our discussion, the `UrlGenerator` is supposed to replace `Controller::generateFrontendUrl`.\r\n\r\nIt allows for simple but flexible use of Contao urls (or pages actually).\r\n\r\n 1. `$urlGenerator->generate('foo');`\r\n\r\n    > Result: `/foo.html`\r\n\r\n 2. `$urlGenerator->generate('index');`\r\n\r\n    > Result: `/`\r\n\r\n 3. `$urlGenerator->generate('foo/{items}', ['items' => 'bar']);`\r\n\r\n    > Result: `/foo/items/bar.html` if `items` **is not** in `$GLOBALS['TL_AUTO_ITEM']`\r\n    > Result: `/foo/bar.html` if `items` **is** in `$GLOBALS['TL_AUTO_ITEM']`\r\n\r\n 4. `$urlGenerator->generate('foo/{items}', ['items' => 'bar', 'auto_item' => 'items']);`\r\n\r\n    > Result: `/foo/bar.html` (regardless of `$GLOBALS['TL_AUTO_ITEM']`)\r\n\r\n 5. `$urlGenerator->generate('foo/{items}/{article}', ['items' => 'bar', 'article' => 'test');`\r\n\r\n    > Result: `/foo/bar/article/test.html` (assuming `items` **is** in `$GLOBALS['TL_AUTO_ITEM']`)\r\n\r\n 6. `$urlGenerator->generate('foo/{items}.html', ['items' => 'bar', 'article' => 'test');`\r\n\r\n    > Result: `/foo/bar.html?article=test` (assuming `items` **is** in `$GLOBALS['TL_AUTO_ITEM']`)\r\n\r\n 7. Example with `PageModel`\r\n     ```php\r\n    $page = \\Contao\\PageModel::findWithDetails(/* ... */);\r\n\r\n    $urlGenerator->generate(\r\n        $page->alias ?: $page->id, \r\n        [\r\n            '_locale' => $page->rootLanguage,\r\n            '_domain' => $page->domain,\r\n            '_ssl' => (bool) $page->rootUseSSL,\r\n        ]\r\n    );\r\n    ```\r\n\r\n**ToDo**\r\n - [x] Handle host and schema\r\n - [ ] Add docblocks with extensive info \r\n - [ ] More unit tests ?"},"comment":{"url":"https://api.github.com/repos/contao/core-bundle/issues/comments/217445256","html_url":"https://github.com/contao/core-bundle/pull/480#issuecomment-217445256","issue_url":"https://api.github.com/repos/contao/core-bundle/issues/480","id":217445256,"user":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"created_at":"2016-05-06T13:49:06Z","updated_at":"2016-05-06T13:49:06Z","body":"PR updated and added a 7th example"}}