X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=9c5bc8cc840cac66477dc743edccb90832eeec58;hp=9cc2a0699e353b31ccf90432f94ed091fa1a9f25;hb=4ac0b9cb8e9043db8a95f44af685c782bf9426e7;hpb=b354201608d428db344c63dd35de096a62a7a9d3 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 9cc2a06..9c5bc8c 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1109,7 +1109,7 @@ EOF =head2 $app->setup_finalize A hook to attach modifiers to. -Using C< after setup => sub{}; > doesn't work, because of quirky things done for plugin setup. +Using C<< after setup => sub{}; >> doesn't work, because of quirky things done for plugin setup. Also better than C< setup_finished(); >, as that is a getter method. sub setup_finalize { @@ -1224,6 +1224,38 @@ sub uri_for { $res; } +=head2 $c->uri_for_action( $path, \@captures?, @args?, \%query_values? ) + +=head2 $c->uri_for_action( $action, \@captures?, @args?, \%query_values? ) + +=over + +=item $path + +A private path to the Catalyst action you want to create a URI for. + +This is a shortcut for calling C<< $c->dispatcher->get_action_by_path($path) +>> and passing the resulting C<$action> and the remaining arguments to C<< +$c->uri_for >>. + +You can also pass in a Catalyst::Action object, in which case it is passed to +C<< $c->uri_for >>. + +=back + +=cut + +sub uri_for_action { + my ( $c, $path, @args ) = @_; + my $action = blessed($path) + ? $path + : $c->dispatcher->get_action_by_path($path); + unless (defined $action) { + croak "Can't find action for path '$path'"; + } + return $c->uri_for( $action, @args ); +} + =head2 $c->welcome_message Returns the Catalyst welcome HTML page.