line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Workflow::Context; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
1199
|
use warnings; |
|
21
|
|
|
|
|
42
|
|
|
21
|
|
|
|
|
840
|
|
4
|
21
|
|
|
21
|
|
151
|
use strict; |
|
21
|
|
|
|
|
59
|
|
|
21
|
|
|
|
|
653
|
|
5
|
21
|
|
|
21
|
|
121
|
use base qw( Workflow::Base ); |
|
21
|
|
|
|
|
42
|
|
|
21
|
|
|
|
|
5432
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$Workflow::Context::VERSION = '1.62'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
11
|
27
|
|
|
27
|
1
|
91
|
my ( $self, %params) = @_; |
12
|
|
|
|
|
|
|
|
13
|
27
|
|
|
|
|
106
|
for my $key (keys %params) { |
14
|
0
|
|
|
|
|
0
|
$self->param( $key => $params{$key} ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub merge { |
19
|
1
|
|
|
1
|
1
|
63
|
my ( $self, $other ) = @_; |
20
|
1
|
|
|
|
|
5
|
my $other_params = $other->param(); |
21
|
1
|
|
|
|
|
2
|
while ( my ( $k, $v ) = each %{$other_params} ) { |
|
2
|
|
|
|
|
16
|
|
22
|
1
|
|
|
|
|
3
|
$self->param( $k, $v ); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__END__ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=pod |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Workflow::Context - Data blackboard for Workflows, Actions, Conditions and Validators |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 VERSION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This documentation describes version 1.62 of this package |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Create your own context and merge it with one that may already be |
43
|
|
|
|
|
|
|
# in a workflow |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $context = Workflow::Context->new(); |
46
|
|
|
|
|
|
|
$context->param( foo => 'bar' ); |
47
|
|
|
|
|
|
|
$context->param( current_user => User->fetch( 'foo@bar.com' ) ); |
48
|
|
|
|
|
|
|
my $wf = FACTORY()->create_workflow( 'w/f', $context ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# The above is the same as: |
51
|
|
|
|
|
|
|
$context = Workflow::Context->new( |
52
|
|
|
|
|
|
|
foo => 'bar', |
53
|
|
|
|
|
|
|
current_user => User->fetch( 'foo@bar.com' ), |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
$wf = FACTORY()->create_workflow( 'w/f', $context ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# In a Condition get the 'current_user' back out of the workflow's context |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub evaluate { |
61
|
|
|
|
|
|
|
my ( $self, $wf ) = @_; |
62
|
|
|
|
|
|
|
my $current_user = $wf->context->param( 'current_user' ); |
63
|
|
|
|
|
|
|
... |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Set values directly into a workflow's context |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$wf->context->param( foo => 'bar' ); |
69
|
|
|
|
|
|
|
$wf->context->param( news => My::News->fetch_where( 'date = ?', DateTime->now ) ); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DESCRIPTION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Holds information to pass between your application and a Workflow, |
74
|
|
|
|
|
|
|
including its Actions, Conditions and Validators. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 init( %params ) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Adds C<%params> to the context at instantiation. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 merge( $other_context ) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Merges the values from C<$other_context> into this object. If there |
85
|
|
|
|
|
|
|
are duplicate keys in this object and C<$other_context>, |
86
|
|
|
|
|
|
|
C<$other_context> wins. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SEE ALSO |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * L<Workflow> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Copyright (c) 2003-2023 Chris Winters. All rights reserved. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
101
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Please see the F<LICENSE> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHORS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Please see L<Workflow> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |