{"action":"created","issue":{"url":"https://api.github.com/repos/zendframework/zend-expressive/issues/325","repository_url":"https://api.github.com/repos/zendframework/zend-expressive","labels_url":"https://api.github.com/repos/zendframework/zend-expressive/issues/325/labels{/name}","comments_url":"https://api.github.com/repos/zendframework/zend-expressive/issues/325/comments","events_url":"https://api.github.com/repos/zendframework/zend-expressive/issues/325/events","html_url":"https://github.com/zendframework/zend-expressive/issues/325","id":136963593,"number":325,"title":"Url helpers produces unexpected results when querystring and/or optional route params in stage","user":{"login":"edigu","id":435857,"avatar_url":"https://avatars.githubusercontent.com/u/435857?v=3","gravatar_id":"","url":"https://api.github.com/users/edigu","html_url":"https://github.com/edigu","followers_url":"https://api.github.com/users/edigu/followers","following_url":"https://api.github.com/users/edigu/following{/other_user}","gists_url":"https://api.github.com/users/edigu/gists{/gist_id}","starred_url":"https://api.github.com/users/edigu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edigu/subscriptions","organizations_url":"https://api.github.com/users/edigu/orgs","repos_url":"https://api.github.com/users/edigu/repos","events_url":"https://api.github.com/users/edigu/events{/privacy}","received_events_url":"https://api.github.com/users/edigu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":35,"created_at":"2016-02-27T20:30:09Z","updated_at":"2016-10-11T18:30:20Z","closed_at":null,"body":"I hit this problem today when trying to implement a pagination template using **Twig** as template renderer.\r\n\r\nI have a catch-all route for user-related operations and trying to handle multiple actions in a single class like [documented in cookbook](https://zendframework.github.io/zend-expressive/cookbook/using-routed-middleware-class-as-controller/).\r\n\r\n```\r\n[\r\n    'name'            => 'user',\r\n    'path'            => '/user[/{action:add|edit|show|list}[/{id}]]',\r\n    'middleware'      => Action\\UserActions::class,\r\n    'allowed_methods' => ['GET','POST'],\r\n],\r\n```\r\n\r\nAnd I want to generate a uri path with additional arguments using helper like below:\r\n\r\n```\r\n{{ path(\"user\", { \"page\" : 1 } ) }}\r\n```\r\n\r\nExpected output: `/user?page=1`\r\nActual output: `/user[/{action:add|edit|show|list}[/{id}]]`\r\nProblem(s) : Helper exposing the original route in view layer and `page` argument is lost.\r\n\r\nOther examples:\r\n\r\n```\r\n{{ path(\"user\") }}\r\n```\r\nExpected output: `/user`\r\nActual output: `/user[/{act:add|edit|show|list}[/{id}]]`\r\n\r\n```\r\n{{ path(\"user\" { \"act\":null, \"id\":null } ) }}\r\n```\r\nExpected output: `/user`\r\nActual output: `/location[/[/]]`\r\n\r\nI have not tried yet with the the zend-router. I believe there should be a way to create routes with querystring arguments.\r\n\r\nSeems like `generateUri()` method of the [Zend\\Expressive\\Router\\FastrouteRouter](https://github.com/zendframework/zend-expressive-fastroute/blob/master/src/FastRouteRouter.php#L129-L167) is responsible but I'm not sure that.\r\n\r\nI have also tried switching the router from **FastRouter** to **AuraRouter**:\r\n\r\n````\r\n[\r\n    'name'            => 'user',\r\n    'path'            => '/user{/act,id}',\r\n    'middleware'      => Action\\UserActions::class,\r\n    'allowed_methods' => ['GET'],\r\n    'options'         => [\r\n        'tokens' => [\r\n            'act'    => '(add|edit|show|list)?',\r\n            'id'     => '\\d+',\r\n            ]\r\n    ],\r\n],\r\n```\r\n\r\nNow, when I try to generate relative uri;\r\n\r\n```\r\n{{ path(\"user\", { \"page\" : 1 } ) }}\r\n```\r\n\r\nExpected output: `/user?page=1`\r\nActual output: `/user`\r\nResult : My route definitions are not exposed but page argument is still lost.\r\n\r\nAm i missing something? what is the proper way to create URL's with querystring arguments in expressive?"},"comment":{"url":"https://api.github.com/repos/zendframework/zend-expressive/issues/comments/253003564","html_url":"https://github.com/zendframework/zend-expressive/issues/325#issuecomment-253003564","issue_url":"https://api.github.com/repos/zendframework/zend-expressive/issues/325","id":253003564,"user":{"login":"xtreamwayz","id":9497586,"avatar_url":"https://avatars.githubusercontent.com/u/9497586?v=3","gravatar_id":"","url":"https://api.github.com/users/xtreamwayz","html_url":"https://github.com/xtreamwayz","followers_url":"https://api.github.com/users/xtreamwayz/followers","following_url":"https://api.github.com/users/xtreamwayz/following{/other_user}","gists_url":"https://api.github.com/users/xtreamwayz/gists{/gist_id}","starred_url":"https://api.github.com/users/xtreamwayz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtreamwayz/subscriptions","organizations_url":"https://api.github.com/users/xtreamwayz/orgs","repos_url":"https://api.github.com/users/xtreamwayz/repos","events_url":"https://api.github.com/users/xtreamwayz/events{/privacy}","received_events_url":"https://api.github.com/users/xtreamwayz/received_events","type":"User","site_admin":false},"created_at":"2016-10-11T18:30:20Z","updated_at":"2016-10-11T18:30:20Z","body":"@glen-84 You are mixing two things here. We are talking about how the UrlHelper has to look like. How it looks like for the twig renderer is something different. Even though the url helper might require an array with `_query` and `_fragment`, I can change the twig renderer in anyway we like. You can even write your own twig extension. The only thing that would affect this is calling the UrlHelper directly in (for example) an action.\r\n\r\nAlso _route is not what you think it is. _route would be the option to reuse the current route result. That is not something what would be called from twig directly since you don't have / don't need access the route result in your template.\r\n\r\nEventually it might something like this for twig:\r\n\r\n```twig\r\n{{ path('routename'), {<parameters>}, {<options like query, fragment, reuseRouteResult>}) }}\r\n\r\n{{ path('routeName', {foo: bar}, {query: {param: 1}, fragment: test, reuseResult: false}) }}\r\n```"}}
{"actor":{"display_login":"xtreamwayz"}}