Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WorkflowMessage - Allow more dynamic-localized data. Unify language field. #26618

Merged
merged 11 commits into from
Jun 23, 2023
Merged
Prev Previous commit
Next Next commit
WorkflowMessage - Add getWorkflowName() and getGroupName()
  • Loading branch information
totten committed Jun 23, 2023
commit b8218aeec76a791c8dfddaf02a03194b244dd12f
1 change: 1 addition & 0 deletions Civi/Test/WorkflowMessageTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ protected function assertSameWorkflowMessage(\Civi\WorkflowMessage\WorkflowMessa
if ($prefix === NULL) {
$prefix = sprintf('[%s] ', $this->getWorkflowName());
}
$this->assertEquals($refInstance->getWorkflowName(), $cmpInstance->getWorkflowName(), "{$prefix}Should have same workflow name)");
$this->assertEquals($refInstance->export('tplParams'), $cmpInstance->export('tplParams'), "{$prefix}Should have same export(tplParams)");
$this->assertEquals($refInstance->export('tokenContext'), $cmpInstance->export('tokenContext'), "{$prefix}should have same export(tokenContext)");
$this->assertEquals($refInstance->export('envelope'), $cmpInstance->export('envelope'), "{$prefix}Should have same export(envelope)");
Expand Down
14 changes: 14 additions & 0 deletions Civi/WorkflowMessage/Traits/ReflectiveWorkflowTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@
*/
trait ReflectiveWorkflowTrait {

public function getWorkflowName(): ?string {
return $this->_extras['envelope']['workflow'] ?? \CRM_Utils_Constant::value(static::CLASS . '::WORKFLOW');
}

/**
* @return string|null
* @deprecated
* It is not recommended that new things depend on the group-name. However, the plumbing still
* passes-through the group-name.
*/
public function getGroupName(): ?string {
return $this->_extras['envelope']['groupName'] ?? \CRM_Utils_Constant::value(static::CLASS . '::GROUP');
}

/**
* 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
Expand Down
5 changes: 5 additions & 0 deletions Civi/WorkflowMessage/WorkflowMessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

interface WorkflowMessageInterface {

/**
* @return string
*/
public function getWorkflowName(): ?string;

/**
* @return \Civi\WorkflowMessage\FieldSpec[]
* A list of field-specs that are used in the given format, keyed by their name in that format.
Expand Down