From 7517e5afc191163e6de0060714fc9cdec5a3ad50 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 24 Jun 2023 22:40:53 -0700 Subject: [PATCH] Add workflow message template for sign_petition This should make tokens available (once added per https://github.com/civicrm/civicrm-core/pull/26650 but no actual runtime change as yet --- .../PetitionConfirmationNeeded.php | 59 +++++++++++++++++++ CRM/Campaign/WorkflowMessage/PetitionSign.php | 48 +++++++++++++++ .../WorkflowMessage/Survey/Survey.php | 59 +++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 CRM/Campaign/WorkflowMessage/PetitionConfirmationNeeded.php create mode 100644 CRM/Campaign/WorkflowMessage/PetitionSign.php create mode 100644 CRM/Campaign/WorkflowMessage/Survey/Survey.php diff --git a/CRM/Campaign/WorkflowMessage/PetitionConfirmationNeeded.php b/CRM/Campaign/WorkflowMessage/PetitionConfirmationNeeded.php new file mode 100644 index 0000000000..5a3759b696 --- /dev/null +++ b/CRM/Campaign/WorkflowMessage/PetitionConfirmationNeeded.php @@ -0,0 +1,59 @@ + 'workflow/' . $workflow . '/basic_eur', + 'title' => ts('Save the whales'), + 'tags' => ['preview'], + 'workflow' => $workflow, + ]; + } + } + + /** + * Build an example to use when rendering the workflow. + * + * @param array $example + * + * @throws \CRM_Core_Exception + */ + 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 \Civi\WorkflowMessage\GenericWorkflowMessage $messageTemplate + * + * @throws \CRM_Core_Exception + */ + private function addExampleData(GenericWorkflowMessage $messageTemplate): void { + $messageTemplate->setContact(\Civi\Test::example('entity/Contact/Barb')); + $messageTemplate->setSurvey([ + 'id' => 60, + 'title' => ts('Save the whales'), + ]); + } + +} -- 2.25.1