X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=4113fed42af5991d43b5dd6cacff90c043b14431;hp=8eb58389f490bb20bdce28f14422a83cdd845c34;hb=d5e3d528ff5f0cbe8796e78fc87573653d929712;hpb=2f3812528068bc1d9f7840067f0c03d36cd47e6d diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 8eb5838..4113fed 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -76,7 +76,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.7099_03'; +our $VERSION = '5.8000_02'; sub import { my ( $class, @arguments ) = @_; @@ -346,13 +346,33 @@ When called with no arguments it escapes the processing chain entirely. sub detach { my $c = shift; $c->dispatcher->detach( $c, @_ ) } +=head2 $c->visit( $action [, \@arguments ] ) + +=head2 $c->visit( $class, $method, [, \@arguments ] ) + +Almost the same as C, but does a full dispatch, instead of just +calling the new C<$action> / C<$class-E$method>. This means that C, +C and the method you go to are called, just like a new request. + +C<$c-Estash> is kept unchanged. + +In effect, C allows you to "wrap" another action, just as it +would have been called by dispatching from a URL, while the analogous +C allows you to transfer control to another action as if it had +been reached directly from a URL. + +=cut + +sub visit { my $c = shift; $c->dispatcher->visit( $c, @_ ) } + =head2 $c->go( $action [, \@arguments ] ) =head2 $c->go( $class, $method, [, \@arguments ] ) -Almost the same as C, but does a full dispatch, instead of just -calling the new C<$action> / C<$class-E$method>. This means that C, -C and the method you go to is called, just like a new request. +Almost the same as C, but does a full dispatch like C, +instead of just calling the new C<$action> / +C<$class-E$method>. This means that C, C and the +method you visit are called, just like a new request. C<$c-Estash> is kept unchanged. @@ -506,7 +526,7 @@ sub _comp_names { sub _filter_component { my ( $c, $comp, @args ) = @_; - if ( eval { $comp->can('ACCEPT_CONTEXT'); } ) { + if ( Scalar::Util::blessed($c) && eval { $comp->can('ACCEPT_CONTEXT'); } ) { return $comp->ACCEPT_CONTEXT( $c, @args ); } @@ -993,26 +1013,33 @@ EOF $class->setup_finished(1); } +=head2 $c->uri_for( $action, \@captures?, @args?, \%query_values? ) + =head2 $c->uri_for( $path, @args?, \%query_values? ) -Merges path with C<< $c->request->base >> for absolute URIs and with -C<< $c->namespace >> for relative URIs, then returns a normalized L -object. If any args are passed, they are added at the end of the path. -If the last argument to C is a hash reference, it is assumed to -contain GET parameter key/value pairs, which will be appended to the URI -in standard fashion. +=over + +=item $action -Note that uri_for is destructive to the passed hashref. Subsequent calls -with the same hashref may have unintended results. +A Catalyst::Action object representing the Catalyst action you want to +create a URI for. To get one for an action in the current controller, +use C<< $c->action('someactionname') >>. To get one from different +controller, fetch the controller using C<< $c->controller() >>, then +call C on it. -Instead of C<$path>, you can also optionally pass a C<$action> object -which will be resolved to a path using -C<< $c->dispatcher->uri_for_action >>; if the first element of -C<@args> is an arrayref it is treated as a list of captures to be passed -to C. +You can maintain the arguments captured by an action (e.g.: Regex, Chained) +using C<< $c->req->captures >>. + + # For the current action + $c->uri_for($c->action, $c->req->captures); + + # For the Foo action in the Bar controller + $c->uri_for($c->controller->('Bar')->action_for('Foo'), $c->req->captures); =cut +=back + sub uri_for { my ( $c, $path, @args ) = @_; @@ -2475,6 +2502,8 @@ Gary Ashton Jones Geoff Richards +ilmari: Dagfinn Ilmari Mannsåker + jcamacho: Juan Camacho Jody Belka @@ -2505,6 +2534,8 @@ omega: Andreas Marienborg phaylon: Robert Sedlacek +rafl: Florian Ragwitz + sky: Arthur Bergman the_jester: Jesse Sheidlower