Sync automation email step settings to newsletter entity

[MAILPOET-4515]
This commit is contained in:
Jan Jakes 2022-07-28 16:15:20 +02:00 committed by Veljko V
parent 15e4635fe3
commit 4389d3ca5f
2 changed files with 21 additions and 0 deletions

View File

@ -101,6 +101,24 @@ class SendEmailAction implements Action {
}
}
public function saveEmailSettings(Step $step): void {
if ($step->getKey() !== $this->getKey()) {
return;
}
$args = $step->getArgs();
if (!isset($args['email_id'])) {
return;
}
$email = $this->getEmailForStep($step);
$email->setSubject($args['subject'] ?? '');
$email->setPreheader($args['preheader'] ?? '');
$email->setSenderName($args['from_name'] ?? '');
$email->setSenderAddress($args['email'] ?? '');
$this->newslettersRepository->flush();
}
private function getEmailForStep(Step $step): NewsletterEntity {
$emailId = $step->getArgs()['email_id'] ?? null;
if (!$emailId) {

View File

@ -39,5 +39,8 @@ class MailPoetIntegration implements Integration {
$registry->addSubject($this->subscriberSubject);
$registry->addTrigger($this->segmentSubscribedTrigger);
$registry->addAction($this->sendEmailAction);
// sync step args (subject, preheader, etc.) to email settings
$registry->onBeforeWorkflowStepSave([$this->sendEmailAction, 'saveEmailSettings']);
}
}