On 10/18/10 2:27 AM, Jordi Boggiano wrote:
So.. some news on this issue that never got much attention:I now have this route set up for example: viewEvent: pattern: /:event/:title defaults: { _controller: eventController:viewEventAction } requirements: { event: \d+, title: '[a-z0-9-]*' } Setting the requirement for title with '*' at the end was the only way to have the title optional, otherwise even if I set "title: ~" in the defaults, the compiled regex will not mark it as optional. Now that's great and all, but I'm still wondering about the trailing slash, is there any way to make it optional too? I could add it to the title pattern for sure since I don't use the title anyway, but that's a bit hackish and ugly.
Can you create a ticket for this issue so that it does not get lost here? Fabien
Cheers On Wed, Feb 24, 2010 at 3:18 PM, Jordi Boggiano<[email protected]> wrote:Heya, So I have this test route with a parameter that I would like to be optional.. test: pattern: /test/:url defaults: _bundle: TestBundle _controller: Test _action: test url: foo There are several problems. First of all, if you set a value like in this case foo, it works but only when calling /test, and it fails on /test/. This is a general issue no matter whether you got optional stuff or not, I think trailing slash shouldn't screw up the route, or at least it'd be nice to have a setting for that, because for example if I use the "Go to parent folder" in Opera it goes from /foo/bar/ to /foo/ with a trailing slash, so I'd like to support such behavior. Second, if you want url to default to null, it doesn't seem possible. I tried with url: '' and url: null, both make it fail when I call /test. This is an absolute requirement in my opinion. Also I was wondering, since you seem to use reflection to order the parameters when calling the controller, couldn't we just define default values in the controller function declaration instead of having to define them in the routing yaml? It sounds better for comprehension of the code when you look at the controller, but that might be just me. Cheers, Jordi
-- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
