X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=af4f7ce789b07f74580205087eb9b6aaf2d58f76;hp=69c8400458123c0c84d14c3a6a018e6f55b7c574;hb=a1dad9c1cde458c1b9429ceca83691607b1ee9c2;hpb=b114f90888d21c4a82cfc4dde4df8396af0ac6d2 diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 69c8400..af4f7ce 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -104,10 +104,13 @@ sub dispatch { } } -=item $c->forward($command) +=item $c->forward($command [args])) Forward processing to a private action or a method from a class. If you define a class without method it will default to process(). +also takes an optional arrayref containing arguments to be passed +to the new function. $c->req->args will be reset upon returning +from the function. $c->forward('/foo'); $c->forward('index'); @@ -127,6 +130,15 @@ sub forward { my $caller = caller(0); my $namespace = '/'; + my $args; + + if ( ref( $_[0] ) eq 'ARRAY' ) { + $args=$c->req->args(); + $c->req->args( shift ); + } elsif ( ref( $_[1] ) eq 'ARRAY' ) { + $args=$c->req->args(); + $c->req->args( $_[1] ); + } if ( $command =~ /^\// ) { $command =~ /^\/(.*)\/(\w+)$/; @@ -184,10 +196,12 @@ sub forward { for my $result ( @{$results} ) { $c->execute( @{ $result->[0] } ); - return if scalar @{ $c->error }; + last if scalar @{ $c->error }; last unless $c->state; } + $c->req->args( $args ) if $args; + return if scalar @{ $c->error }; return $c->state; }