3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
12 namespace Civi\WorkflowMessage
;
14 use Civi\Test\ExampleDataInterface
;
17 * Helper class for defining WorkflowMessage example-data.
19 * By convention, you should name this class relative to the target workflow, as in:
20 * - Workflow Name: case_activity
21 * - Workflow Class: CRM_Case_WorkflowMessage_CaseActivity
22 * - Example Data: CRM_Case_WorkflowMessage_CaseActivity_Foo
23 * - Example Name: workflow/case_activity/foo
25 abstract class WorkflowMessageExample
implements ExampleDataInterface
{
28 * Name of the workflow for which we are providing example data.
31 * Ex: 'CRM_Case_WorkflowMessage_CaseActivity'
36 * Name of the workflow for which we are providing example data.
44 * Name for this example specifically.
51 * WorkflowMessageExample constructor.
53 public function __construct() {
54 if (!preg_match(';^(.*)[_\\\]([a-zA-Z0-9]+)$;', static::class, $m)) {
55 throw new \
RuntimeException("Failed to parse class: " . static::class);
57 $this->wfClass
= $m[1];
58 $this->wfName
= array_search($m[1], \Civi\WorkflowMessage\WorkflowMessage
::getWorkflowNameClassMap());
59 $this->exName
= $m[2];
63 * Get an example, merge/extend it with more data, and return the extended
67 * Baseline data to build upon.
68 * @param array $overrides
69 * Additional data to recursively add.
72 * The result of merging the original example with the $overrides.
74 public function extend($base, $overrides = []) {
75 \CRM_Utils_Array
::extend($base, $overrides);
79 protected function toArray(\Civi\WorkflowMessage\WorkflowMessageInterface
$wfMsg) {
81 'workflow' => $this->wfName
,
82 'modelProps' => $wfMsg->export('modelProps'),