Skip to content

Commit 6d96b63

Browse files
authored
Add the transition name to workflow notification (#35775)
1 parent 2048a49 commit 6d96b63

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

administrator/language/en-GB/plg_workflow_notification.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PLG_WORKFLOW_NOTIFICATION="Workflow - Notification"
99
PLG_WORKFLOW_NOTIFICATION_ADDTEXT="The stage has changed"
1010
PLG_WORKFLOW_NOTIFICATION_ADDTEXT_DESC="This text will be sent: Title [title], changed by [user], new state: [state]. You can add own text to this information. You can localise the text by using a language key and creating a language override."
1111
PLG_WORKFLOW_NOTIFICATION_ADDTEXT_LABEL="Additional Message Text"
12-
PLG_WORKFLOW_NOTIFICATION_ON_TRANSITION_MSG="Title: %1$s, changed by %2$s, new state: %3$s."
12+
PLG_WORKFLOW_NOTIFICATION_ON_TRANSITION_MSG="Title: %1$s. Transition %2$s performed by %3$s. New state: %4$s."
1313
PLG_WORKFLOW_NOTIFICATION_ON_TRANSITION_SUBJECT="The status of an %1$s has been changed"
1414
PLG_WORKFLOW_NOTIFICATION_RECEIVERS_LABEL="Users"
1515
PLG_WORKFLOW_NOTIFICATION_SENDMAIL_LABEL="Send Notification"

plugins/workflow/notification/notification.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ public function onWorkflowAfterTransition(WorkflowTransitionEvent $event)
180180

181181
$toStage = $model_stage->getItem($transition->to_stage_id)->title;
182182

183+
// Get the nameif the transition
184+
$model_transition = $this->app->bootComponent('com_workflow')
185+
->getMVCFactory()->createModel('Transition', 'Administrator');
186+
187+
$transitionName = $model_transition->getItem($transition->id)->title;
188+
183189
$hasGetItem = method_exists($model, 'getItem');
184190
$container = Factory::getContainer();
185191

@@ -204,7 +210,12 @@ public function onWorkflowAfterTransition(WorkflowTransitionEvent $event)
204210
$lang = $container->get(LanguageFactoryInterface::class)
205211
->createLanguage($user->getParam('admin_language', $defaultLanguage), $debug);
206212
$lang->load('plg_workflow_notification');
207-
$messageText = sprintf($lang->_('PLG_WORKFLOW_NOTIFICATION_ON_TRANSITION_MSG'), $title, $user->name, $lang->_($toStage));
213+
$messageText = sprintf($lang->_('PLG_WORKFLOW_NOTIFICATION_ON_TRANSITION_MSG'),
214+
$title,
215+
$lang->_($transitionName),
216+
$user->name,
217+
$lang->_($toStage)
218+
);
208219

209220
if (!empty($transition->options['notification_text']))
210221
{

0 commit comments

Comments
 (0)