From e5e486d0cf5c22ab86bd0415e214a621e720f98c Mon Sep 17 00:00:00 2001
From: Torsten Oppermann <torsten@sgalinski.de>
Date: Tue, 11 Sep 2018 15:19:51 +0200
Subject: [PATCH] [TASK] Add setting to ignore the mail queue with the forms
 finisher

---
 Classes/Finisher/Forms/FormsFinisher.php      |  4 +++-
 Configuration/Yaml/Forms/FinisherSetupBE.yaml | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Classes/Finisher/Forms/FormsFinisher.php b/Classes/Finisher/Forms/FormsFinisher.php
index 17e96919..9090540b 100644
--- a/Classes/Finisher/Forms/FormsFinisher.php
+++ b/Classes/Finisher/Forms/FormsFinisher.php
@@ -70,13 +70,15 @@ class FormsFinisher extends AbstractFinisher {
 			$templateName = $formDefinition->getIdentifier();
 		}
 
+		$ignoreMailQueue = (boolean) $this->parseOption('ignoreMailQueue');
+
 		$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
 		/** @var \SGalinski\SgMail\Service\MailTemplateService $mailTemplateService */
 		$mailTemplateService = $objectManager->get(
 			MailTemplateService::class, $templateName, $this->parseOption('extension'), $markers
 		);
 
-		$mailTemplateService->setIgnoreMailQueue(FALSE);
+		$mailTemplateService->setIgnoreMailQueue($ignoreMailQueue);
 		$mailTemplateService->setLanguage($GLOBALS['TSFE']->config['config']['language']);
 		$mailTemplateService->setSubject($this->parseOption('subject'));
 		$mailTemplateService->setToAddresses($this->parseOption('mailTo'));
diff --git a/Configuration/Yaml/Forms/FinisherSetupBE.yaml b/Configuration/Yaml/Forms/FinisherSetupBE.yaml
index 0accac84..8848d3c8 100644
--- a/Configuration/Yaml/Forms/FinisherSetupBE.yaml
+++ b/Configuration/Yaml/Forms/FinisherSetupBE.yaml
@@ -14,6 +14,7 @@ TYPO3:
                     extension: 'sg_mail'
                     template: ''
                     automaticRegistration: ''
+                    ignoreMailQueue: true
                     mailTo: ''
                     subject: ''
                     userName: ''
@@ -30,6 +31,7 @@ TYPO3:
                     extension: 'sg_mail'
                     template: ''
                     automaticRegistration: ''
+                    ignoreMailQueue: true
                     mailTo: ''
                     mailFrom: ''
                     subject: ''
@@ -75,6 +77,11 @@ TYPO3:
                           templateName: 'Inspector-CheckboxEditor'
                           label: 'Automatic Registration (If selected, you can find your template in the "Mail Template" module after saving. Look for the extension and template key in the dropdown in the upper left corner of the template editor.'
                           propertyPath: 'options.automaticRegistration'
+                        127:
+                          identifier: 'ignoreMailQueue'
+                          templateName: 'Inspector-CheckboxEditor'
+                          label: 'If selected, the mails are send immediately, otherwise the mails are added to the Mail Queue. See the Readme of the sg_mail extension for more Informations.'
+                          propertyPath: 'options.ignoreMailQueue'
                         130:
                           identifier: 'mailTo'
                           templateName: 'Inspector-TextEditor'
@@ -139,6 +146,11 @@ TYPO3:
                           templateName: 'Inspector-CheckboxEditor'
                           label: 'Automatic Registration (If selected, you can find your template in the "Mail Template" module after saving. Look for the extension and template key in the dropdown in the upper left corner of the template editor.'
                           propertyPath: 'options.automaticRegistration'
+                        127:
+                          identifier: 'ignoreMailQueue'
+                          templateName: 'Inspector-CheckboxEditor'
+                          label: 'If selected, the mails are send immediately, otherwise the mails are added to the Mail Queue. See the Readme of the sg_mail extension for more Informations.'
+                          propertyPath: 'options.ignoreMailQueue'
                         130:
                           identifier: 'mailTo'
                           templateName: 'Inspector-TextEditor'
-- 
GitLab