Merge pull request #22560 from eileenmcnaughton/fin_type
[civicrm-core.git] / CRM / Contribute / WorkflowMessage / RecurringEdit.php
CommitLineData
1c4160c3
EM
1<?php
2
54f8b0cd 3/**
66125803 4 * @support template-only
54f8b0cd
TO
5 * @method array getContact()
6 * @method $this setContact(array $contact)
7 * @method array getContributionRecur()
54f8b0cd 8 */
1c4160c3 9class CRM_Contribute_WorkflowMessage_RecurringEdit extends Civi\WorkflowMessage\GenericWorkflowMessage {
e589a77b
EM
10 use CRM_Contribute_WorkflowMessage_RecurringTrait;
11
12 public const WORKFLOW = 'contribution_recurring_edit';
1c4160c3
EM
13
14 /**
15 * The recurring contribution contact.
16 *
17 * @var array|null
18 *
19 * @scope tokenContext
20 *
21 * @required
22 */
23 public $contact;
24
66125803
TO
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
1c4160c3
EM
36 protected function exportExtraTokenContext(array &$export): void {
37 $export['smartyTokenAlias']['installments'] = 'contribution_recur.installments';
38 $export['smartyTokenAlias']['amount'] = 'contribution_recur.amount';
39851eb3 39 $export['smartyTokenAlias']['recur_frequency_unit'] = 'contribution_recur.frequency_unit:label';
1c4160c3
EM
40 $export['smartyTokenAlias']['recur_frequency_interval'] = 'contribution_recur.frequency_interval';
41 }
42
66125803
TO
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
1c4160c3 50}