1Catalyst::ActionChain(3U)ser Contributed Perl DocumentatiCoantalyst::ActionChain(3)
2
3
4
6 Catalyst::ActionChain - Chain of Catalyst Actions
7
9 See Catalyst::Manual::Intro for more info about Chained actions.
10
12 This class represents a chain of Catalyst Actions. It behaves exactly
13 like the action at the *end* of the chain except on dispatch it will
14 execute all the actions in the chain in order.
15
17 chain
18 Accessor for the action chain; will be an arrayref of the
19 Catalyst::Action objects encapsulated by this chain.
20
21 dispatch( $c )
22 Dispatch this action chain against a context; will dispatch the
23 encapsulated actions in order.
24
25 from_chain( \@actions )
26 Takes a list of Catalyst::Action objects and constructs and returns a
27 Catalyst::ActionChain object representing a chain of these actions
28
29 number_of_captures
30 Returns the total number of captures for the entire chain of actions.
31
32 match_captures
33 Match all the captures that this chain encloses, if any.
34
35 scheme
36 Any defined scheme for the actionchain
37
38 next ( @args)
39 Dispatches to the next action in the chain immediately, suspending any
40 remaining code in the action. If there are no more actions in the
41 chain, this is basically a no-op. When the last action in the chain
42 returns, we will return to the last action that called next and
43 continue processing that action's code exactly where it was left off.
44 If more than one action in the chain called "next" then we proceed back
45 up the chain stack in reverse order of calls after the last action
46 completes.
47
48 The return value of "next" is the return value of the next action in
49 the chain (that is the action that was called with "next") or whatever
50 $c->state is set to.
51
52 Please note that since "state" is a scalar, you cannot return a list of
53 values from an action chain. If you want to return a list you must
54 return an arrayref or hashref. This limitation is due to longstanding
55 code in Catalyst that is not easily changed without breaking backwards
56 compatibility.
57
58 You can call "next" in as many actions in a long chain as you want and
59 the chain will correctly return to the last action that called "next"
60 based on order of execution. If there are actions inbetween that
61 didn't call "next", those will be skipped when proceeding back up the
62 call stack. When we've completed walking back up the action call stack
63 the dispatcher will then return to normal processing order (for example
64 processing any "end" action present).
65
66 Any arguments you pass to "next" will be passed to the next action in
67 the chain as "$c->request->arguments". You can pass more than one
68 argument. All arguments passed via "next" will be added into the
69 argument list prior to any CaptureArgs or Args that the action itself
70 defines.
71
72 Example:
73
74 sub action_a :Chained('/') CaptureArgs(0) {
75 my ($self, $ctx) = @_;
76 my $abc = $c->action->next('a'); # $abc = "abc";
77 }
78
79 sub action_b :Chained('action_a') CaptureArgs(0) {
80 my ($self, $ctx, $a) = @_;
81 my $abc = $c->action->next("${a}b");
82 return $abc;
83 }
84
85 sub action_c :Chained('action_b') Args(0) {
86 my ($self, $ctx, $ab) = @_;
87 return "${ab}c";
88 }
89
90 meta
91 Provided by Moose
92
94 Catalyst Contributors, see Catalyst.pm
95
97 This library is free software. You can redistribute it and/or modify it
98 under the same terms as Perl itself.
99
100
101
102perl v5.38.0 2023-07-24 Catalyst::ActionChain(3)