Commit | Line | Data |
---|---|---|
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 | 9 | class 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 | ||
1c75b02d EM |
36 | /** |
37 | * Export tokens to smarty as variables. | |
38 | * | |
39 | * The key represents the smarty token and the value is the token as | |
40 | * requested from the token processor. | |
41 | * | |
42 | * The token is 'the entire part between the curly quotes' eg. | |
43 | * | |
44 | * '{contribution_recur.amount|crmMoney}. | |
45 | * | |
46 | * Unlike using the contribution directly it will default to 'raw' formatting. | |
47 | * | |
48 | * @param array $export | |
49 | */ | |
1c4160c3 EM |
50 | protected function exportExtraTokenContext(array &$export): void { |
51 | $export['smartyTokenAlias']['installments'] = 'contribution_recur.installments'; | |
1c75b02d | 52 | $export['smartyTokenAlias']['amount'] = 'contribution_recur.amount|crmMoney'; |
39851eb3 | 53 | $export['smartyTokenAlias']['recur_frequency_unit'] = 'contribution_recur.frequency_unit:label'; |
1c4160c3 EM |
54 | $export['smartyTokenAlias']['recur_frequency_interval'] = 'contribution_recur.frequency_interval'; |
55 | } | |
56 | ||
1c75b02d EM |
57 | /** |
58 | * Extra variables to be exported to smarty based on being calculated. | |
59 | * | |
60 | * @param array $export | |
61 | */ | |
66125803 TO |
62 | protected function exportExtraTplParams(array &$export): void { |
63 | if (empty($export['receipt_from_email']) && !empty($this->from)) { | |
64 | // At a minimum, we can at least autofill 'receipt_from_email' in the case where it's missing. | |
65 | $export['receipt_from_email'] = $this->getFrom('record')['email']; | |
66 | } | |
67 | } | |
68 | ||
1c4160c3 | 69 | } |