1 package Catalyst::ActionChain;
6 extends qw(Catalyst::Action);
8 has chain => (is => 'rw');
14 Catalyst::ActionChain - Chain of Catalyst Actions
18 See L<Catalyst::Manual::Intro> for more info about Chained actions.
22 This class represents a chain of Catalyst Actions. It behaves exactly like
23 the action at the *end* of the chain except on dispatch it will execute all
24 the actions in the chain in order.
29 my ( $self, $c ) = @_;
30 my @captures = @{$c->req->captures||[]};
31 my @chain = @{ $self->chain };
32 my $last = pop(@chain);
33 foreach my $action ( @chain ) {
35 if (my $cap = $action->attributes->{CaptureArgs}) {
36 @args = splice(@captures, 0, $cap->[0]);
38 local $c->request->{arguments} = \@args;
39 $action->dispatch( $c );
41 $last->dispatch( $c );
45 my ( $self, $actions ) = @_;
46 my $final = $actions->[-1];
47 return $self->new({ %$final, chain => $actions });
50 __PACKAGE__->meta->make_immutable;
59 Accessor for the action chain; will be an arrayref of the Catalyst::Action
60 objects encapsulated by this chain.
64 Dispatch this action chain against a context; will dispatch the encapsulated
67 =head2 from_chain( \@actions )
69 Takes a list of Catalyst::Action objects and constructs and returns a
70 Catalyst::ActionChain object representing a chain of these actions
82 This program is free software, you can redistribute it and/or modify it under
83 the same terms as Perl itself.