1 package Reaction::UI::Controller::Role::RedirectTo;
6 my ($self, $c, $to, $cap, $args, $attrs) = @_;
9 "Using redirect_to is now deprecated and may be removed in the future."
12 #the confess calls could be changed later to $c->log ?
14 my $reftype = ref($to);
16 $action = $self->action_for($to);
17 confess("Failed to locate action ${to} in " . blessed($self)) unless $action;
18 } elsif($reftype eq 'ARRAY' && @$to == 2){ #is that overkill / too strict?
19 $action = $c->controller($to->[0])->action_for($to->[1]);
20 confess("Failed to locate action $to->[1] in $to->[0]" ) unless $action;
21 } elsif( blessed $to && $to->isa('Catalyst::Action') ){
24 confess("Failed to locate action from ${to}");
27 $cap ||= $c->req->captures;
28 $args ||= $c->req->args;
30 my $uri = $c->uri_for($action, $cap, @$args, $attrs);
31 $c->res->redirect($uri);
41 Reaction::UI::Controller::Role::RedirectTo
45 Provides a C<redirect_to> method, which aims to be a more convenient way to
46 create internal redirects vs C<Catalyst::uri_for> and C<Catalyst::Response::redirect>
48 =head1 DEPRECATION NOTICE
50 This method was separated out of L<Catalyst::Controller> to facilitate deprecation.
51 The behavior of this method is, by design, flawed and you should aim to replace
52 any instances of it in your codebase;
56 =head2 redirect_to $c, 'action_name', \@captures, \@args, \%query_parms
58 =head2 redirect_to $c, $action_object, \@captures, \@args, \%query_parms
60 =head2 redirect_to $c, [ Controller_name => 'action_name' ], \@captures, \@args, \%query_parms
62 Will create a uri from the arguments given and redirect to it without detaching.
63 If captures and arguments are not explicitly given, the ones from the current
64 request will be used. If query-parameters are not given, none will be used.
66 The first argument after C<$c> cab be one of three, the name of an action present
67 in the controller returned by C<$c-E<gt>controller>, an action object, or an
68 array reference contraining 2 items, a controller name and an action name.
72 See L<Reaction::Class> for authors.
76 See L<Reaction::Class> for the license.