From d65c516186210b0de4a5fff33774e99c79cd3e0f Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 11 Oct 2024 11:46:21 +1300 Subject: [PATCH] ENH Update code to reflect changes in template layer --- src/Actions/NotifyUsersWorkflowAction.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Actions/NotifyUsersWorkflowAction.php b/src/Actions/NotifyUsersWorkflowAction.php index e9eaeaf7..08d68f6f 100644 --- a/src/Actions/NotifyUsersWorkflowAction.php +++ b/src/Actions/NotifyUsersWorkflowAction.php @@ -3,6 +3,7 @@ namespace Symbiote\AdvancedWorkflow\Actions; use SilverStripe\Control\Email\Email; +use SilverStripe\Core\Injector\Injector; use SilverStripe\Forms\HeaderField; use SilverStripe\Forms\LiteralField; use SilverStripe\Forms\TextareaField; @@ -14,7 +15,8 @@ use SilverStripe\Security\Member; use SilverStripe\Security\Security; use SilverStripe\Model\ArrayData; -use SilverStripe\View\SSViewer; +use SilverStripe\View\TemplateEngine; +use SilverStripe\View\ViewLayerData; use Swift_RfcComplianceException; use Symbiote\AdvancedWorkflow\DataObjects\WorkflowAction; use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance; @@ -134,10 +136,7 @@ public function execute(WorkflowInstance $workflow) ]); } - - $view = SSViewer::fromString($this->EmailTemplate); - $this->extend('updateView', $view); - + $engine = Injector::inst()->create(TemplateEngine::class); foreach ($members as $member) { if ($member->Email) { // We bind in the assignee at this point, as it changes each loop iteration @@ -146,7 +145,7 @@ public function execute(WorkflowInstance $workflow) $item->Assignee = ArrayData::create($assigneeVars); } - $body = $view->process($item); + $body = $engine->renderString($this->EmailTemplate, ViewLayerData::create($item)); $email = Email::create(); try {