CRM_Core_BAO_MessageTemplate::sendTemplate(
[
'groupName' => 'msg_tpl_workflow_petition',
- 'valueName' => 'petition_sign',
+ 'workflow' => 'petition_sign',
'contactId' => $params['contactId'],
'tplParams' => $tplParams,
'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>",
CRM_Core_BAO_MessageTemplate::sendTemplate(
[
'groupName' => 'msg_tpl_workflow_petition',
- 'valueName' => 'petition_confirmation_needed',
+ 'workflow' => 'petition_confirmation_needed',
'contactId' => $params['contactId'],
'tplParams' => $tplParams,
'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>",
list($result[CRM_Utils_Array::value('contact_id', $info)], $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(
[
'groupName' => 'msg_tpl_workflow_case',
- 'valueName' => 'case_activity',
+ 'workflow' => 'case_activity',
'contactId' => $info['contact_id'] ?? NULL,
'tplParams' => $tplParams,
'from' => $receiptFrom,
// send duplicate alert, if dupe match found during on-behalf-of processing.
if (!empty($values['onbehalf_dupe_alert'])) {
$sendTemplateParams['groupName'] = 'msg_tpl_workflow_contribution';
- $sendTemplateParams['valueName'] = 'contribution_dupalert';
+ $sendTemplateParams['workflow'] = 'contribution_dupalert';
$sendTemplateParams['from'] = ts('Automatically Generated') . " <{$values['receipt_from_email']}>";
$sendTemplateParams['toName'] = $values['receipt_from_name'] ?? NULL;
$sendTemplateParams['toEmail'] = $values['receipt_from_email'] ?? NULL;
[$displayName, $email] = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution['contact_id'], FALSE);
$templatesParams = [
'groupName' => 'msg_tpl_workflow_contribution',
- 'valueName' => 'contribution_recurring_notify',
+ 'workflow' => 'contribution_recurring_notify',
'contactId' => $contribution['contact_id'],
'tplParams' => [
'recur_frequency_interval' => $recur->frequency_interval,
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$sendTemplateParams = [
'groupName' => 'msg_tpl_workflow_contribution',
- 'valueName' => 'pcp_owner_notify',
+ 'workflow' => 'pcp_owner_notify',
'contactId' => $contributionSoft['contact_id'],
'toEmail' => $ownerEmail,
'toName' => $ownerName,
$sendTemplateParams
= [
'groupName' => $this->_mode == 'auto_renew' ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution',
- 'valueName' => $this->_mode == 'auto_renew' ? 'membership_autorenew_cancelled' : 'contribution_recurring_cancelled',
+ 'workflow' => $this->_mode == 'auto_renew' ? 'membership_autorenew_cancelled' : 'contribution_recurring_cancelled',
'contactId' => $this->getSubscriptionDetails()->contact_id,
'tplParams' => $tplParams,
'tokenContext' => ['contribution_recurId' => $this->getContributionRecurID()],
$sendTemplateParams = array(
'groupName' => $this->getSubscriptionDetails()->membership_id ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution',
- 'valueName' => $this->getSubscriptionDetails()->membership_id ? 'membership_autorenew_billing' : 'contribution_recurring_billing',
+ 'workflow' => $this->getSubscriptionDetails()->membership_id ? 'membership_autorenew_billing' : 'contribution_recurring_billing',
'contactId' => $this->getSubscriptionDetails()->contact_id,
'tplParams' => $tplParams,
'isTest' => $this->getSubscriptionDetails()->is_test,
$sendTemplateParams = [
'groupName' => 'msg_tpl_workflow_contribution',
- 'valueName' => 'contribution_recurring_edit',
+ 'workflow' => 'contribution_recurring_edit',
'contactId' => $contactID,
'tplParams' => ['receipt_from_email' => $receiptFrom],
'isTest' => $this->_subscriptionDetails->is_test,
$modelDefaults = [
// instance of WorkflowMessageInterface, containing a list of data to provide to the message-template
'model' => NULL,
- // Symbolic name of the workflow step. Matches the option-value-name of the template.
- 'valueName' => NULL,
+ // Symbolic name of the workflow step. Matches the value in civicrm_msg_template.workflow_name.
+ 'workflow' => NULL,
// additional template params (other than the ones already set in the template singleton)
'tplParams' => [],
// additional token params (passed to the TokenProcessor)
$params = array_merge($modelDefaults, $viewDefaults, $envelopeDefaults, $params);
CRM_Utils_Hook::alterMailParams($params, 'messageTemplate');
- $mailContent = self::loadTemplate((string) $params['valueName'], $params['isTest'], $params['messageTemplateID'] ?? NULL, $params['groupName'] ?? '', $params['messageTemplate'], $params['subject'] ?? NULL);
+ $mailContent = self::loadTemplate((string) $params['workflow'], $params['isTest'], $params['messageTemplateID'] ?? NULL, $params['groupName'] ?? '', $params['messageTemplate'], $params['subject'] ?? NULL);
self::synchronizeLegacyParameters($params);
$rendered = CRM_Core_TokenSmarty::render(CRM_Utils_Array::subset($mailContent, ['text', 'html', 'subject']), $params['tokenContext'], $params['tplParams']);
* @param array $params
*/
private static function synchronizeLegacyParameters(&$params) {
+ // 'valueName' is deprecated, docs were updated some time back
+ // and people have been notified. Having it here means the
+ // hooks will still see it until we remove.
CRM_Utils_Array::pathSync($params, ['workflow'], ['valueName']);
CRM_Utils_Array::pathSync($params, ['tokenContext', 'contactId'], ['contactId']);
CRM_Utils_Array::pathSync($params, ['tokenContext', 'smarty'], ['disableSmarty'], function ($v, bool $isCanon) {
// Group name & valueName are deprecated parameters. At some point it will not be passed out.
// https://github.com/civicrm/civicrm-core/pull/17180
'groupName' => $groupName,
- 'valueName' => $workflowName,
+ 'workflow' => $workflowName,
];
CRM_Utils_Hook::alterMailContent($mailContent);
CRM_Core_BAO_MessageTemplate::sendTemplate(
[
'groupName' => 'msg_tpl_workflow_uf',
- 'valueName' => 'uf_notify',
+ 'workflow' => 'uf_notify',
'contactId' => $contactID,
'tplParams' => [
'displayName' => $displayName,
$sendTemplateParams = [
'groupName' => 'msg_tpl_workflow_event',
- 'valueName' => 'event_online_receipt',
+ 'workflow' => 'event_online_receipt',
'contactId' => $contactID,
'isTest' => $isTest,
'tplParams' => $tplParams,
$sendTemplateParams = [
'groupName' => 'msg_tpl_workflow_event',
- 'valueName' => 'event_online_receipt',
+ 'workflow' => 'event_online_receipt',
'contactId' => $participantDetails[$participant->id]['contact_id'],
'tplParams' => $tplParams,
'from' => $receiptFrom,
$sendTemplateParams = [
'groupName' => 'msg_tpl_workflow_contribution',
- 'valueName' => 'payment_or_refund_notification',
+ 'workflow' => 'payment_or_refund_notification',
'PDFFilename' => ts('notification') . '.pdf',
'contactId' => $entities['contact']['id'],
'toName' => $entities['contact']['display_name'],
$templateParams = [
'groupName' => 'msg_tpl_workflow_friend',
- 'valueName' => 'friend',
+ 'workflow' => 'friend',
'contactId' => $contactID,
'tplParams' => [
$values['module'] => $values['module'],
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(
[
'groupName' => 'msg_tpl_workflow_contribution',
- 'valueName' => $tplName,
+ 'workflow' => $tplName,
'contactId' => $pcpInfo['contact_id'],
'tplParams' => $tplParams,
'from' => $receiptFrom,
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(
[
'groupName' => 'msg_tpl_workflow_contribution',
- 'valueName' => 'pcp_notify',
+ 'workflow' => 'pcp_notify',
'contactId' => $contactID,
'from' => "$domainEmailName <$domainEmailAddress>",
'toEmail' => $to,
[$sent, $subject, $message, $html] = CRM_Core_BAO_MessageTemplate::sendTemplate(
[
'groupName' => 'msg_tpl_workflow_pledge',
- 'valueName' => 'pledge_acknowledge',
+ 'workflow' => 'pledge_acknowledge',
'contactId' => $params['contact_id'],
'from' => $receiptFrom,
'toName' => $pledgerDisplayName,
] = CRM_Core_BAO_MessageTemplate::sendTemplate(
[
'groupName' => 'msg_tpl_workflow_pledge',
- 'valueName' => 'pledge_reminder',
+ 'workflow' => 'pledge_reminder',
'contactId' => $contactId,
'from' => $receiptFrom,
'toName' => $pledgerName,
_civicrm_api3_message_template_send_spec($fieldSpec);
foreach ($fieldSpec as $field => $spec) {
- if (isset($spec['api.aliases']) && array_key_exists($field, $params)) {
+ // There is some dark magic going on here.
+ // The point of the 'api.aliases' metadata is generally
+ // to ensure that old params can be passed in and they still work.
+ // However, in this case the api params don't match the BAO
+ // params so the names that have been determined as
+ // 'right' for the api are being transformed into
+ // the 'wrong' BAO ones. It works, it's tested &
+ // we can do better in apiv4 once we get a suitable
+ // api there.
+ if ($spec['name'] !== 'workflow' && isset($spec['api.aliases']) && array_key_exists($field, $params)) {
$params[CRM_Utils_Array::first($spec['api.aliases'])] = $params[$field];
unset($params[$field]);
}
}
if (empty($params['messageTemplateID'])) {
- if (empty($params['valueName'])) {
+ if (empty($params['workflow'])) {
// Can't use civicrm_api3_verify_mandatory for this because it would give the wrong field names
throw new API_Exception(
- 'Mandatory key(s) missing from params array: requires id or option_value_name',
+ 'Mandatory key(s) missing from params array: requires id or workflow',
'mandatory_missing',
- ['fields' => ['id', 'option_value_name']]
+ ['fields' => ['id', 'workflow']]
);
}
}
$params['id']['api.aliases'] = ['messageTemplateID', 'message_template_id'];
$params['id']['type'] = CRM_Utils_Type::T_INT;
- $params['option_value_name']['description'] = 'option value name of the template (required if no id supplied)';
- $params['option_value_name']['title'] = 'Option Value Name';
- $params['option_value_name']['api.aliases'] = ['valueName'];
- $params['option_value_name']['type'] = CRM_Utils_Type::T_STRING;
+ $params['workflow']['description'] = 'option value name of the template (required if no id supplied)';
+ $params['workflow']['title'] = ts('Workflow');
+ $params['workflow']['api.aliases'] = ['option_value_name', 'valueName'];
+ $params['workflow']['type'] = CRM_Utils_Type::T_STRING;
+ $params['workflow']['name'] = 'workflow';
$params['contact_id']['description'] = 'contact id if contact tokens are to be replaced';
$params['contact_id']['title'] = 'Contact ID';
'is_pay_later' => $this->is_pay_later,
'pay_later_receipt' => $this->pay_later_receipt,
],
- 'valueName' => 'event_registration_receipt',
+ 'workflow' => 'event_registration_receipt',
'PDFFilename' => ts('confirmation') . '.pdf',
];
$template_params_to_copy = [
'suffix_id' => NULL,
]);
$rendered = CRM_Core_BAO_MessageTemplate::renderTemplate([
- 'valueName' => 'case_activity',
+ 'workflow' => 'case_activity',
'tokenContext' => [
'contactId' => $contactId,
],
]);
[$sent, $subject, $messageText, $messageHtml] = CRM_Core_BAO_MessageTemplate::sendTemplate(
[
- 'valueName' => 'case_activity',
+ 'workflow' => 'case_activity',
'contactId' => $contactId,
'from' => 'admin@example.com',
// No 'toEmail'/'toName' address => not sendable, but still returns rendered value.
[$sent, $subject, $messageText, $messageHtml] = CRM_Core_BAO_MessageTemplate::sendTemplate(
[
- 'valueName' => 'case_activity',
+ 'workflow' => 'case_activity',
'contactId' => $contactId,
'from' => 'admin@example.com',
// No 'toEmail'/'toName' address => not sendable, but still returns rendered value.
[$sent, $subject, $messageText, $messageHtml] = CRM_Core_BAO_MessageTemplate::sendTemplate(
[
- 'valueName' => 'case_activity',
+ 'workflow' => 'case_activity',
'tokenContext' => [
'contactId' => $contactId,
'activityId' => $activityId,
$this->assertEquals([], \Civi\Test\Invasive::get([$msg, '_extras']));
[, $subject, $message] = $msg->sendTemplate([
- 'valueName' => 'case_activity',
+ 'workflow' => 'case_activity',
'from' => 'admin@example.com',
'toName' => 'Demo',
'toEmail' => 'admin@example.com',
$tokenString = '{domain.' . implode('} ~ {domain.', array_keys($values)) . '}';
$messageContent = CRM_Core_BAO_MessageTemplate::renderTemplate([
- 'valueName' => 'dummy',
+ 'workflow' => 'dummy',
'messageTemplate' => [
'msg_html' => $tokenString,
// Check the space is stripped.
*/
public function testRenderTemplateSmarty(): void {
$messageContent = CRM_Core_BAO_MessageTemplate::renderTemplate([
- 'valueName' => 'dummy',
+ 'workflow' => 'dummy',
'messageTemplate' => [
'msg_html' => '{$tokenString}',
// Check the space is stripped.
*/
public function testRenderTemplateIgnoreSmarty(): void {
$messageContent = CRM_Core_BAO_MessageTemplate::renderTemplate([
- 'valueName' => 'dummy',
+ 'workflow' => 'dummy',
'messageTemplate' => [
'msg_html' => '{$tokenString}',
// Check the space is stripped.
$tokenString .= "{$key}:{contact.{$key}}\n";
}
$messageContent = CRM_Core_BAO_MessageTemplate::renderTemplate([
- 'valueName' => 'dummy',
+ 'workflow' => 'dummy',
'messageTemplate' => [
'msg_html' => $tokenString,
// Check the space is stripped.