Merge pull request #22313 from mlutfy/eventDefaultUrlValues
[civicrm-core.git] / CRM / Contribute / WorkflowMessage / RecurringEdit.php
1 <?php
2
3 /**
4 * @support template-only
5 * @method array getContact()
6 * @method $this setContact(array $contact)
7 * @method array getContributionRecur()
8 */
9 class CRM_Contribute_WorkflowMessage_RecurringEdit extends Civi\WorkflowMessage\GenericWorkflowMessage {
10 use CRM_Contribute_WorkflowMessage_RecurringTrait;
11
12 public const WORKFLOW = 'contribution_recurring_edit';
13
14 /**
15 * The recurring contribution contact.
16 *
17 * @var array|null
18 *
19 * @scope tokenContext
20 *
21 * @required
22 */
23 public $contact;
24
25 /**
26 * Smarty template historically defined a property 'receipt_from_email'.
27 * (Note the asymmetric lack of 'receipt_from_name'.)
28 *
29 * TODO: This should probably be deprecated/converted/reconciled with `$this->from` in the basic AddressingTrait.
30 *
31 * @var string|null
32 * @scope tplParams as receipt_from_email
33 */
34 public $receiptFromEmail;
35
36 protected function exportExtraTokenContext(array &$export): void {
37 $export['smartyTokenAlias']['installments'] = 'contribution_recur.installments';
38 $export['smartyTokenAlias']['amount'] = 'contribution_recur.amount';
39 $export['smartyTokenAlias']['recur_frequency_unit'] = 'contribution_recur.frequency_unit:label';
40 $export['smartyTokenAlias']['recur_frequency_interval'] = 'contribution_recur.frequency_interval';
41 }
42
43 protected function exportExtraTplParams(array &$export): void {
44 if (empty($export['receipt_from_email']) && !empty($this->from)) {
45 // At a minimum, we can at least autofill 'receipt_from_email' in the case where it's missing.
46 $export['receipt_from_email'] = $this->getFrom('record')['email'];
47 }
48 }
49
50 }