forked from kaliop-uk/ezworkflowenginebundle
/
FillComments.yml
80 lines (72 loc) · 1.99 KB
/
FillComments.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# This workflow is designed to demo the capability of using http calls to external systems to alter cms contents.
#
# When a content is published of type 'comment', and the 'body' field has been left void, fill it with 'lore ipsum' text
# hook up to post-publication
-
type: workflow
signal: ContentService\PublishVersionSignal
avoid_recursion: true
# load the content to be able to set a reference to its class
-
type: content
mode: load
match:
content_id: workflow:signal:content_id
references:
-
identifier: content_type_fc
attribute: content_type_identifier
# cancel the workflow if the content is not of the desired type
-
type: workflow
mode: cancel
unless:
"reference:content_type_fc":
eq: "comment"
# set references to the content fields
-
type: content
mode: load
match:
content_id: workflow:signal:content_id
references:
-
identifier: comment_message
attribute: attributes.message
# help with debugging: dump current references to a file for inspection
-
# Save the complete set of references currently defined to a json or yaml file
type: reference
mode: save
file: "./refs.json"
overwrite: true
# cancel the workflow if the body field is not null
-
type: workflow
mode: cancel
unless:
and:
-
"reference:content_type_fc":
eq: "comment"
-
"reference:comment_message":
eq: null
# get a bunch of lorem ipsum text to be used to fill in the body
-
type: http
mode: call
client: acme
uri: "http://loripsum.net/api/3/plaintext"
references:
-
attribute: body
identifier: lipsum_text
# and set it into the comment by republishing it
-
type: content
mode: update
match:
content_id: workflow:signal:content_id
attributes:
message: "reference:lipsum_text"