X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=8cccb9a47ec144cf82bfb1d6db41cd8b72851f68;hb=9b0ec7a17caeecd0df1b4a855469777befa2e9d5;hp=1068f27a5e14180945e32ec485df3b68438d761f;hpb=0eb4af722418c249c10885d55a93cb8adfa2729b;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 1068f27..8cccb9a 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -865,6 +865,11 @@ end of the path. If the last argument to uri_for is a hash reference, it is assumed to contain GET parameter key/value pairs, which will be appended to the URI in standard fashion. +Instead of $path, you can also optionally pass a $action object which will +be resolved to a path using $c->dispatcher->uri_for_action; if the first +element of @args is an arrayref it is treated as a list of captures to be +passed to uri_for_action. + =cut sub uri_for { @@ -875,6 +880,14 @@ sub uri_for { $basepath .= '/'; my $namespace = $c->namespace || ''; + if ( Scalar::Util::blessed($path) ) { # action object + my $captures = ( scalar @args && ref $args[0] eq 'ARRAY' + ? shift(@args) + : [] ); + $path = $c->dispatcher->uri_for_action($path, $captures); + return undef unless defined($path); + } + # massage namespace, empty if absolute path $namespace =~ s/^\/// if $namespace; $namespace .= '/' if $namespace;