X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=23a5ea961c788b6ec0cd50001a7ce247222d13ab;hp=8eb58389f490bb20bdce28f14422a83cdd845c34;hb=ae0e35ee6dd51e78c0ffc2457699beadc7eefab8;hpb=2f3812528068bc1d9f7840067f0c03d36cd47e6d diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 8eb5838..23a5ea9 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -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 ); } @@ -1011,6 +1031,15 @@ 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 sub uri_for { @@ -2475,6 +2504,8 @@ Gary Ashton Jones Geoff Richards +ilmari: Dagfinn Ilmari Mannsåker + jcamacho: Juan Camacho Jody Belka @@ -2505,6 +2536,8 @@ omega: Andreas Marienborg phaylon: Robert Sedlacek +rafl: Florian Ragwitz + sky: Arthur Bergman the_jester: Jesse Sheidlower