Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
8990a43f
Unverified
Commit
8990a43f
authored
3 years ago
by
colemanw
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #22636 from eileenmcnaughton/exampley
Add basic contribution example base for contribution workflows
parents
5d22ac64
42d1c64c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Contribute/WorkflowMessage/Contribution/BasicContribution.ex.php
+59
-0
59 additions, 0 deletions
...ute/WorkflowMessage/Contribution/BasicContribution.ex.php
Civi/WorkflowMessage/WorkflowMessageExample.php
+20
-0
20 additions, 0 deletions
Civi/WorkflowMessage/WorkflowMessageExample.php
with
79 additions
and
0 deletions
CRM/Contribute/WorkflowMessage/Contribution/BasicContribution.ex.php
0 → 100644
+
59
−
0
View file @
8990a43f
<?php
use
Civi\Api4\WorkflowMessage
;
use
Civi\WorkflowMessage\GenericWorkflowMessage
;
use
Civi\WorkflowMessage\WorkflowMessageExample
;
/**
* Basic contribution example for contribution templates.
*
* @noinspection PhpUnused
* @noinspection UnknownInspectionInspection
*/
class
CRM_Contribute_WorkflowMessage_Contribution_BasicContribution
extends
WorkflowMessageExample
{
/**
* Get the examples this class is able to deliver.
*/
public
function
getExamples
():
iterable
{
$workflows
=
[
'contribution_online_receipt'
,
'contribution_offline_receipt'
,
'contribution_invoice_receipt'
];
foreach
(
$workflows
as
$workflow
)
{
yield
[
'name'
=>
'workflow/'
.
$workflow
.
'/'
.
$this
->
getExampleName
(),
'title'
=>
ts
(
'Completed Contribution'
),
'tags'
=>
[
'preview'
],
'workflow'
=>
$workflow
,
];
}
}
/**
* Build an example to use when rendering the workflow.
*
* @param array $example
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public
function
build
(
array
&
$example
):
void
{
$workFlow
=
WorkflowMessage
::
get
(
TRUE
)
->
addWhere
(
'name'
,
'='
,
$example
[
'workflow'
])
->
execute
()
->
first
();
$this
->
setWorkflowName
(
$workFlow
[
'name'
]);
$messageTemplate
=
new
$workFlow
[
'class'
]();
$this
->
addExampleData
(
$messageTemplate
);
$example
[
'data'
]
=
$this
->
toArray
(
$messageTemplate
);
}
/**
* Add relevant example data.
*
* @param \CRM_Contribute_WorkflowMessage_ContributionOfflineReceipt|\CRM_Contribute_WorkflowMessage_ContributionOnlineReceipt|\CRM_Contribute_WorkflowMessage_ContributionInvoiceReceipt $messageTemplate
*
* @throws \CRM_Core_Exception
*/
private
function
addExampleData
(
GenericWorkflowMessage
$messageTemplate
):
void
{
$messageTemplate
->
setContact
(
\Civi\Test
::
example
(
'entity/Contact/Barb'
));
$messageTemplate
->
setContribution
(
\Civi\Test
::
example
(
'entity/Contribution/Euro5990/completed'
));
}
}
This diff is collapsed.
Click to expand it.
Civi/WorkflowMessage/WorkflowMessageExample.php
+
20
−
0
View file @
8990a43f
...
...
@@ -40,6 +40,17 @@ abstract class WorkflowMessageExample implements ExampleDataInterface {
*/
protected
$wfName
;
/**
* Set the workflow name.
*
* The workflow name is the value in civicrm_message_template.workflow.
*
* @param string $workflowName
*/
public
function
setWorkflowName
(
string
$workflowName
):
void
{
$this
->
wfName
=
$workflowName
;
}
/**
* Name for this example specifically.
*
...
...
@@ -47,6 +58,15 @@ abstract class WorkflowMessageExample implements ExampleDataInterface {
*/
protected
$exName
;
/**
* Get the example name.
*
* @return string
*/
public
function
getExampleName
():
string
{
return
$this
->
exName
;
}
/**
* WorkflowMessageExample constructor.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment