Skip to content

Commit e57fbb9

Browse files
committed
Add notifications to export/import
1 parent 80bb15d commit e57fbb9

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎ProcessMaker/Jobs/ExportProcess.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ private function removeAssignedEntities()
9898
*/
9999
private function packageProcess()
100100
{
101-
$this->package['process'] = $this->process->toArray();
102-
$this->package['process']['bpmn'] = $this->process->bpmn;
101+
$this->package['process'] = $this->process->append('notifications', 'task_notifications')->toArray();
102+
$this->package['process']['bpmn'] = $this->process->bpmn;
103103
}
104104

105105
/**

‎ProcessMaker/Jobs/ImportProcess.php‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use ProcessMaker\Models\User;
1212
use ProcessMaker\Models\Process;
1313
use ProcessMaker\Models\ProcessCategory;
14+
use ProcessMaker\Models\ProcessNotificationSetting;
1415
use ProcessMaker\Models\Screen;
1516
use ProcessMaker\Models\Script;
1617
use Illuminate\Queue\SerializesModels;
@@ -356,6 +357,33 @@ private function saveProcess($process)
356357
$new->created_at = $this->formatDate($process->created_at);
357358
$new->deleted_at = $this->formatDate($process->deleted_at);
358359
$new->save();
360+
361+
foreach ($process->notifications as $notifiable => $notificationTypes) {
362+
foreach ($notificationTypes as $notificationType => $wanted) {
363+
if ($wanted === true) {
364+
$newNotification = new ProcessNotificationSetting;
365+
$newNotification->process_id = $new->id;
366+
$newNotification->notifiable_type = $notifiable;
367+
$newNotification->notification_type = $notificationType;
368+
$newNotification->save();
369+
}
370+
}
371+
}
372+
373+
foreach ($process->task_notifications as $elementId => $notifiables) {
374+
foreach ($notifiables as $notifiable => $notificationTypes) {
375+
foreach ($notificationTypes as $notificationType => $wanted) {
376+
if ($wanted === true) {
377+
$newNotification = new ProcessNotificationSetting;
378+
$newNotification->process_id = $new->id;
379+
$newNotification->element_id = $elementId;
380+
$newNotification->notifiable_type = $notifiable;
381+
$newNotification->notification_type = $notificationType;
382+
$newNotification->save();
383+
}
384+
}
385+
}
386+
}
359387

360388
$this->definitions = $new->getDefinitions();
361389
$this->new['process'] = $new;

0 commit comments

Comments
 (0)