1 package Reaction::UI::Controller;
5 Catalyst::Component::ACCEPT_CONTEXT
13 my $c = $self->context;
14 my $focus_stack = $c->stash->{focus_stack};
15 my ($class, @proto_args) = @_;
17 if (my $vp_attr = $c->stack->[-1]->attributes->{ViewPort}) {
18 if (ref($vp_attr) eq 'ARRAY') {
19 $vp_attr = $vp_attr->[0];
21 if (ref($vp_attr) eq 'HASH') {
22 if (my $conf_class = delete $vp_attr->{class}) {
25 %args = (%$vp_attr, @proto_args);
36 if (exists $args{next_action} && !ref($args{next_action})) {
37 $args{next_action} = [ $self, 'redirect_to', $args{next_action} ];
39 $focus_stack->push_viewport($class, %args);
43 return shift->context->stash->{focus_stack}->pop_viewport;
46 sub pop_viewports_to {
48 return $self->context->stash->{focus_stack}->pop_viewports_to($vp);
52 my ($self, $c, $to, $cap, $args, $attrs) = @_;
54 #the confess calls could be changed later to $c->log ?
57 $action = $self->action_for($to);
58 confess("Failed to locate action ${to} in " . $self->blessed) unless $action;
60 elsif( blessed $to && $to->isa('Catalyst::Action') ){
62 } elsif(ref $action eq 'ARRAY' && @$action == 2){ #is that overkill / too strict?
63 $action = $c->controller($to->[0])->action_for($to->[1]);
64 confess("Failed to locate action $to->[1] in $to->[0]" ) unless $action;
66 confess("Failed to locate action from ${to}");
69 $cap ||= $c->req->captures;
70 $args ||= $c->req->args;
72 my $uri = $c->uri_for($action, $cap, @$args, $attrs);
73 $c->res->redirect($uri);