Documentation

ReflectiveWorkflowTrait

The ReflectiveWorkflowTrait makes it easier to define workflow-messages using conventional PHP class-modeling. Thus:

  • As general rule, you define all inputs+outputs as PHP properties.
  • All key WorkflowMessage methods (getFields, import, export, validate) are based reflection (inspecting types/annotations of the PHP properties).
  • Most common tasks can be done with annotations on the properties such as @var and @scope.
  • If you need special behaviors (e.g. outputting derived data to the Smarty context automatically), then you may override certain methods (e.g. exportExtra*(), importExtra*()).

Here are few important annotations:

  • @var - Specify the PHP type for the data. (Use '|' to list multiple permitted types.) Ex: @var string|bool
  • @scope - Share data with another subsystem, such as the token-processor (tokenContext) or Smarty (tplParams). (By default, the property will have the same name in the other context, but) Ex: @scope tplParams Ex: @scope tplParams as contact_id, tokenContext as contactId

Table of Contents

Properties

$_extras  : array<string|int, mixed>
The extras are an open-ended list of fields that will be passed-through to tpl, tokenContext, etc. This is the storage of last-resort for imported values that cannot be stored by other means.

Methods

export()  : array<string|int, mixed>|null
getFields()  : array<string|int, mixed>
getGroupName()  : string|null
getWorkflowName()  : string|null
import()  : mixed
validate()  : array<string|int, mixed>
Determine if the data for this workflow message is complete/well-formed.
exportExtraEnvelope()  : void
Get a list of key-value pairs to include the Smarty template context.
exportExtraModelProps()  : void
Get a list of key-value pairs to include the array-coded version of the class.
exportExtraTokenContext()  : void
Get a list of key-value pairs to add to the token-context.
exportExtraTplParams()  : void
Get a list of key-value pairs to include the Smarty template context.
getFieldsByFormat()  : array<string|int, mixed>|null
importExtraEnvelope()  : void
Given an import-array (in the envelope-format), pull out any interesting values.
importExtraModelProps()  : void
Given an import-array (in the class-format), pull out any interesting values.
importExtraTokenContext()  : void
Given an import-array (in the token-context-format), pull out any interesting values.
importExtraTplParams()  : void
Given an import-array (in the tpl-format), pull out any interesting values.

Properties

$_extras

The extras are an open-ended list of fields that will be passed-through to tpl, tokenContext, etc. This is the storage of last-resort for imported values that cannot be stored by other means.

protected array<string|int, mixed> $_extras = []

Ex: ['tplParams' => ['assigned_value' => 'A', 'other_value' => 'B']]

Methods

getGroupName()

public getGroupName() : string|null

It is not recommended that new things depend on the group-name. However, the plumbing still passes-through the group-name.

Return values
string|null

validate()

Determine if the data for this workflow message is complete/well-formed.

public validate() : array<string|int, mixed>
Tags
see
WorkflowMessageInterface::validate()
Return values
array<string|int, mixed>

A list of errors and warnings. Each record defines

  • severity: string, 'error' or 'warning'
  • fields: string[], list of fields implicated in the error
  • name: string, symbolic name of the error/warning
  • message: string, printable message describing the problem

exportExtraEnvelope()

Get a list of key-value pairs to include the Smarty template context.

protected exportExtraEnvelope(array<string|int, mixed> &$export) : void
Parameters
$export : array<string|int, mixed>

Modifiable list of export-values.

exportExtraModelProps()

Get a list of key-value pairs to include the array-coded version of the class.

protected exportExtraModelProps(array<string|int, mixed> &$export) : void
Parameters
$export : array<string|int, mixed>

Modifiable list of export-values.

exportExtraTokenContext()

Get a list of key-value pairs to add to the token-context.

protected exportExtraTokenContext(array<string|int, mixed> &$export) : void
Parameters
$export : array<string|int, mixed>

Modifiable list of export-values.

exportExtraTplParams()

Get a list of key-value pairs to include the Smarty template context.

protected exportExtraTplParams(array<string|int, mixed> &$export) : void

Values returned here will override any defaults.

Parameters
$export : array<string|int, mixed>

Modifiable list of export-values.

getFieldsByFormat()

protected getFieldsByFormat(mixed $format) : array<string|int, mixed>|null
Parameters
$format : mixed
Return values
array<string|int, mixed>|null

importExtraEnvelope()

Given an import-array (in the envelope-format), pull out any interesting values.

protected importExtraEnvelope(array<string|int, mixed> &$values) : void
Parameters
$values : array<string|int, mixed>

List of import-values. Optionally, unset values that you have handled or blocked.

importExtraModelProps()

Given an import-array (in the class-format), pull out any interesting values.

protected importExtraModelProps(array<string|int, mixed> &$values) : void
Parameters
$values : array<string|int, mixed>

List of import-values. Optionally, unset values that you have handled or blocked.

importExtraTokenContext()

Given an import-array (in the token-context-format), pull out any interesting values.

protected importExtraTokenContext(array<string|int, mixed> &$values) : void
Parameters
$values : array<string|int, mixed>

List of import-values. Optionally, unset values that you have handled or blocked.

importExtraTplParams()

Given an import-array (in the tpl-format), pull out any interesting values.

protected importExtraTplParams(array<string|int, mixed> &$values) : void
Parameters
$values : array<string|int, mixed>

List of import-values. Optionally, unset values that you have handled or blocked.


        
On this page

Search results