*/
protected function exportExtraEnvelope(array &$export): void {
if ($wfName = \CRM_Utils_Constant::value(static::CLASS . '::WORKFLOW')) {
- $export['valueName'] = $wfName;
+ $export['workflow'] = $wfName;
}
if ($wfGroup = \CRM_Utils_Constant::value(static::CLASS . '::GROUP')) {
$export['groupName'] = $wfGroup;
*/
protected function importExtraEnvelope(array &$values): void {
if ($wfName = \CRM_Utils_Constant::value(static::CLASS . '::WORKFLOW')) {
- if (isset($values['valueName']) && $wfName === $values['valueName']) {
- unset($values['valueName']);
+ if (isset($values['workflow']) && $wfName === $values['workflow']) {
+ unset($values['workflow']);
}
}
if ($wfGroup = \CRM_Utils_Constant::value(static::CLASS . '::GROUP')) {
public static function create(string $wfName, array $imports = []) {
$classMap = static::getWorkflowNameClassMap();
$class = $classMap[$wfName] ?? 'Civi\WorkflowMessage\GenericWorkflowMessage';
- $imports['envelope']['valueName'] = $wfName;
+ $imports['envelope']['workflow'] = $wfName;
$model = new $class();
static::importAll($model, $imports);
return $model;
unset($params['model']);
}
-
if (isset($params['tplParams'])) {
$model->import('tplParams', $params['tplParams']);
unset($params['tplParams']);
const WORKFLOW = 'my_example_wf';
- const GROUP = 'my_example_grp';
+ /**
+ * Use this to provide interop with old-style `groupName`.
+ * @deprecated
+ */
+ const GROUP = 'msg_old_style_grp';
/**
* @var string
$this->assertEquals(100, $tpl['some_extra_tpl_stuff']);
$envelope = $ex->export('envelope');
- $this->assertEquals('my_example_wf', $envelope['valueName']);
- $this->assertEquals('my_example_grp', $envelope['groupName']);
+ $this->assertEquals('my_example_wf', $envelope['workflow']);
+ $this->assertEquals('msg_old_style_grp', $envelope['groupName']);
}
/**
$tpl = $ex->export('tplParams');
$this->assertEquals(456, $tpl['myImpromputInt']);
$this->assertEquals(['is not mentioned anywhere'], $tpl['impromptu_smarty_data']);
- $this->assertTrue(!isset($tpl['valueName']));
+ $this->assertTrue(!isset($tpl['workflow']));
$envelope = $ex->export('envelope');
- $this->assertEquals('some_impromptu_wf', $envelope['valueName']);
+ $this->assertEquals('some_impromptu_wf', $envelope['workflow']);
$this->assertEquals('foo@example.com', $envelope['from']);
$this->assertTrue(!isset($envelope['myProtectedInt']));
$ex = $this->createExample()->setContactId($cid);
\Civi::dispatcher()->addListener('hook_civicrm_alterMailParams', function($e) use (&$hookCount) {
$hookCount++;
- $this->assertEquals('my_example_wf', $e->params['valueName'], 'ExampleWorkflow::WORKFLOW should propagate to params[valueName]');
+ $this->assertEquals('my_example_wf', $e->params['workflow'], 'ExampleWorkflow::WORKFLOW should propagate to params[workflow]');
});
$this->assertEquals(0, $hookCount);
$rendered = $ex->renderTemplate([
]);
\Civi::dispatcher()->addListener('hook_civicrm_alterMailParams', function($e) use (&$hookCount) {
$hookCount++;
- $this->assertEquals('some_impromptu_wf', $e->params['valueName'], 'Adhoc name should propagate to params[workflow]');
+ $this->assertEquals('some_impromptu_wf', $e->params['workflow'], 'Adhoc name should propagate to params[workflow]');
});
$this->assertEquals(0, $hookCount);
$rendered = $ex->renderTemplate([
\Civi::dispatcher()->addListener('hook_civicrm_alterMailParams', function($e) use (&$hookCount) {
$hookCount++;
- $this->assertEquals('petition_sign', $e->params['valueName']);
+ $this->assertEquals('petition_sign', $e->params['workflow']);
});
$this->assertEquals(0, $hookCount);
$rendered = $ex->renderTemplate();