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