-
-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22340 from eileenmcnaughton/wktemplates
Add workflow template classes for contributions
- Loading branch information
Showing
7 changed files
with
135 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
CRM/Contribute/WorkflowMessage/ContributionInvoiceReceipt.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
use Civi\WorkflowMessage\GenericWorkflowMessage; | ||
|
||
/** | ||
* Invoice generated when invoicing is enabled. | ||
* | ||
* @support template-only | ||
* @see CRM_Contribute_Form_Task_Invoice::printPDF | ||
*/ | ||
class CRM_Contribute_WorkflowMessage_ContributionInvoiceReceipt extends GenericWorkflowMessage { | ||
|
||
use CRM_Contribute_WorkflowMessage_ContributionTrait; | ||
|
||
public const WORKFLOW = 'contribution_invoice_receipt'; | ||
|
||
/** | ||
* Specify any tokens that should be exported as smarty variables. | ||
* | ||
* @todo it might be that this should be moved to the trait as we | ||
* we work through these. | ||
* | ||
* @param array $export | ||
*/ | ||
protected function exportExtraTokenContext(array &$export): void { | ||
$export['smartyTokenAlias']['currency'] = 'contribution.currency'; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
CRM/Contribute/WorkflowMessage/ContributionOfflineReceipt.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
/** | ||
* Receipt sent when confirming a back office contribution. | ||
* | ||
* @support template-only | ||
* @see CRM_Contribute_Form_AdditionalInfo::emailReceipt | ||
*/ | ||
class CRM_Contribute_WorkflowMessage_ContributionOfflineReceipt extends \Civi\WorkflowMessage\GenericWorkflowMessage { | ||
use CRM_Contribute_WorkflowMessage_ContributionTrait; | ||
public const WORKFLOW = 'contribution_offline_receipt'; | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
CRM/Contribute/WorkflowMessage/ContributionOnlineReceipt.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
use Civi\WorkflowMessage\GenericWorkflowMessage; | ||
|
||
/** | ||
* Receipt sent when confirming contribution add payment. | ||
* | ||
* Add payment, complete order and the front end contribution form | ||
* result in an email send using this, unless an event is involved. | ||
* In addition the api contribution.sendconfirmation and the search task | ||
* call this. | ||
* | ||
* @support template-only | ||
* @see CRM_Contribute_BAO_ContributionPage::sendMail | ||
*/ | ||
class CRM_Contribute_WorkflowMessage_ContributionOnlineReceipt extends GenericWorkflowMessage { | ||
use CRM_Contribute_WorkflowMessage_ContributionTrait; | ||
public const WORKFLOW = 'contribution_online_receipt'; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* @method array getContribution() | ||
* @method ?int getContributionID() | ||
* @method $this setContributionID(?int $contributionId) | ||
*/ | ||
trait CRM_Contribute_WorkflowMessage_ContributionTrait { | ||
/** | ||
* The contribution. | ||
* | ||
* @var array|null | ||
* | ||
* @scope tokenContext as contribution | ||
*/ | ||
public $contribution; | ||
|
||
/** | ||
* @var int | ||
* @scope tokenContext as contribution_id | ||
*/ | ||
public $contributionId; | ||
|
||
/** | ||
* Set contribution object. | ||
* | ||
* @param array $contribution | ||
* | ||
* @return $this | ||
*/ | ||
public function setContribution(array $contribution): self { | ||
$this->contribution = $contribution; | ||
if (!empty($contribution['id'])) { | ||
$this->contributionId = $contribution['id']; | ||
} | ||
return $this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tests/templates/message_templates/contribution_invoice_receipt_html.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
displayName (token):::{contact.display_name} | ||
organizationName (token):::{contact.organization_name} | ||
externalIdentifier (token):::{contact.external_identifier} | ||
currency (token):::{contribution.currency} | ||
currency (smarty):::{$currency} |