Documentation

WorkflowMessage
in package

A WorkflowMessage describes the inputs to an automated email messages.

These classes may be instantiated by either class-name or workflow-name.

Ex: $msgWf = new \CRM_Foo_WorkflowMessage_MyAlert(['tplParams' => [...tplValues...]]); Ex: $msgWf = new \CRM_Foo_WorkflowMessage_MyAlert(['modelProps' => [...classProperties...]]); Ex: $msgWf = WorkflowMessage::create('my_alert_name', ['tplParams' => [...tplValues...]]); Ex: $msgWf = WorkflowMessage::create('my_alert_name', ['modelProps' => [...classProperties...]]);

Instantiating by class-name will provide better hinting and inspection. However, some workflows may not have specific classes at the time of writing. Instantiating by workflow-name will work regardless of whether there is a specific class.

Table of Contents

Methods

create()  : WorkflowMessageInterface
Create a new instance of the workflow-message context.
exportAll()  : array<string|int, mixed>
importAll()  : WorkflowMessageInterface
Import a batch of params, updating the $model.

Methods

create()

Create a new instance of the workflow-message context.

public static create(string $wfName[, array<string|int, mixed> $imports = [] ]) : WorkflowMessageInterface
Parameters
$wfName : string

Name of the workflow. Ex: 'case_activity'

$imports : array<string|int, mixed> = []

List of data to use when populating the message.

The parameters may be given in a mix of formats. This mix reflects two modes of operation:

  • (Informal/Generic) Traditionally, workflow-messages did not have formal parameters. Instead, they relied on a mix of un(der)documented/unverifiable inputs -- supplied as a mix of Smarty assignments, token-data, and sendTemplate() params.
  • (Formal) More recently, workflow-messages could be defined with a PHP class that lists the inputs explicitly.

You may supply inputs using these keys:

  • tplParams (array): Smarty data. These values go to $smarty->assign().
  • tokenContext (array): Token-processing data. These values go to $tokenProcessor->context.
  • envelope (array): Email delivery data. These values go to sendTemplate(...)
  • modelProps (array): Formal parameters defined by a class.

Informal workflow-messages ONLY support 'tplParams', 'tokenContext', and/or 'envelope'. Formal workflow-messages accept any format.

Tags
throws
WorkflowMessageException
Return values
WorkflowMessageInterface

If there is a workflow-message class, then it will return an instance of that class. Otherwise, it will return an instance of GenericWorkflowMessage.

importAll()

Import a batch of params, updating the $model.

public static importAll(WorkflowMessageInterface $model, array<string|int, mixed> $params) : WorkflowMessageInterface
Parameters
$model : WorkflowMessageInterface
$params : array<string|int, mixed>

List of parameters, per MessageTemplate::sendTemplate(). Ex: Initialize using adhoc data: ['tplParams' => [...], 'tokenContext' => [...]] Ex: Initialize using properties of the class-model ['modelProps' => [...]]

Tags
throws
WorkflowMessageException
Return values
WorkflowMessageInterface

The updated model.


        
On this page

Search results