4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
22 * A WorkflowMessage describes the inputs to an automated email messages, and it
23 * allows you to render or preview the content fo automated email messages.
25 * For example, when a constituent donates online, CiviContribute uses the
26 * `contribution_online_receipt` workflow message. This expects certain inputs
27 * (eg `contactId` and `contributionId`) and supports certain tokens
28 * (eg `{contribution.total_amount}`).
30 * WorkflowMessages are related to MessageTemplates (by way of
31 * `WorkflowMessage.name`<=>`MessageTemplate.workflow_name`).
32 * The WorkflowMessage defines the _contract_ or _processing_ of the
33 * message, and the MessageTemplate defines the _literal prose_. The prose
34 * would change frequently (eg for different deployments, locales, timeframes,
35 * and other whims), but contract would change conservatively (eg with a
36 * code-update and with some attention to backward-compatibility/change-management).
42 class WorkflowMessage
extends Generic\AbstractEntity
{
45 * @param bool $checkPermissions
46 * @return Generic\BasicGetAction
48 public static function get($checkPermissions = TRUE) {
49 return (new Generic\
BasicGetAction(__CLASS__
, __FUNCTION__
, function ($get) {
50 return \Civi\WorkflowMessage\WorkflowMessage
::getWorkflowSpecs();
51 }))->setCheckPermissions($checkPermissions);
55 * @param bool $checkPermissions
57 * @return \Civi\Api4\Action\WorkflowMessage\Render
59 public static function render($checkPermissions = TRUE) {
60 return (new Action\WorkflowMessage\
Render(__CLASS__
, __FUNCTION__
))
61 ->setCheckPermissions($checkPermissions);
65 * @param bool $checkPermissions
66 * @return Generic\BasicGetFieldsAction
68 public static function getTemplateFields($checkPermissions = TRUE) {
69 return (new Action\WorkflowMessage\
GetTemplateFields(__CLASS__
, __FUNCTION__
))
70 ->setCheckPermissions($checkPermissions);
74 * @param bool $checkPermissions
75 * @return Generic\BasicGetFieldsAction
77 public static function getFields($checkPermissions = TRUE) {
78 return (new Generic\
BasicGetFieldsAction(__CLASS__
, __FUNCTION__
, function() {
83 'data_type' => 'String',
88 'data_type' => 'String',
93 'data_type' => 'String',
96 'name' => 'description',
97 'title' => 'Description',
98 'data_type' => 'String',
102 'title' => 'Support Level',
104 'experimental' => ts('Experimental: Message may change substantively with no special communication or facilitation.'),
105 'template-only' => ts('Template Support: Changes affecting the content of the message-template will get active support/facilitation.'),
106 'full' => ts('Full Support: All changes affecting message-templates or message-senders will get active support/facilitation.'),
108 'data_type' => 'String',
111 }))->setCheckPermissions($checkPermissions);
114 public static function permissions() {
116 'meta' => ['access CiviCRM'],
117 'default' => ['administer CiviCRM'],
121 'edit message templates',
122 'edit user-driven message templates',
123 'edit system workflow message templates',
133 public static function getInfo() {
134 $info = parent
::getInfo();
135 $info['primary_key'] = ['name'];