From 66057c3c1af63001383cd73e83c5a8adc94cef97 Mon Sep 17 00:00:00 2001 From: groditi Date: Fri, 2 Oct 2009 21:01:17 +0000 Subject: move redirect_to to a role and deprecate it --- lib/Reaction/UI/Controller.pm | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'lib/Reaction/UI/Controller.pm') diff --git a/lib/Reaction/UI/Controller.pm b/lib/Reaction/UI/Controller.pm index 2d1b843..4777ccd 100644 --- a/lib/Reaction/UI/Controller.pm +++ b/lib/Reaction/UI/Controller.pm @@ -7,7 +7,10 @@ use Scalar::Util 'weaken'; use namespace::clean -except => [ qw(meta) ]; has context => (is => 'ro', isa => 'Object', weak_ref => 1); -with 'Catalyst::Component::InstancePerContext'; +with( + 'Catalyst::Component::InstancePerContext', + 'Reaction::UI::Controller::Role::RedirectTo' +); sub build_per_context_instance { my ($self, $c, @args) = @_; @@ -54,31 +57,6 @@ sub pop_viewports_to { return $self->context->stash->{focus_stack}->pop_viewports_to($vp); } -sub redirect_to { - my ($self, $c, $to, $cap, $args, $attrs) = @_; - - #the confess calls could be changed later to $c->log ? - my $action; - my $reftype = ref($to); - if( $reftype eq '' ){ - $action = $self->action_for($to); - confess("Failed to locate action ${to} in " . blessed($self)) unless $action; - } elsif($reftype eq 'ARRAY' && @$to == 2){ #is that overkill / too strict? - $action = $c->controller($to->[0])->action_for($to->[1]); - confess("Failed to locate action $to->[1] in $to->[0]" ) unless $action; - } elsif( blessed $to && $to->isa('Catalyst::Action') ){ - $action = $to; - } else{ - confess("Failed to locate action from ${to}"); - } - - $cap ||= $c->req->captures; - $args ||= $c->req->args; - $attrs ||= {}; - my $uri = $c->uri_for($action, $cap, @$args, $attrs); - $c->res->redirect($uri); -} - sub make_context_closure { my($self, $closure) = @_; my $ctx = $self->context; @@ -115,13 +93,17 @@ Reaction::UI::Controller - Reaction Base Controller Class =head1 DESCRIPTION -Base Reaction Controller class. Inherits from: +Base Reaction Controller class, subclass of L. + +=head1 ROLES CONSUMED =over 4 -=item L -=item L -=item L +=item L + +=item L + +Please not that this functionality is now deprecated. =back -- cgit v1.2.3-54-g00ecf