Skip to content
Snippets Groups Projects
Commit cba83a0c authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[BUGFIX] Cleanups, Newly registered form mail templates missed the proper extension key

parent 4d24df58
No related branches found
No related tags found
No related merge requests found
...@@ -81,9 +81,9 @@ class FormsFinisher extends AbstractFinisher { ...@@ -81,9 +81,9 @@ class FormsFinisher extends AbstractFinisher {
continue; continue;
} }
$formElemenProperties = $formElement->getProperties(); $formElementProperties = $formElement->getProperties();
if (isset($formElemenProperties['markerName']) && \trim($formElemenProperties['markerName']) !== '') { if (isset($formElementProperties['markerName']) && \trim($formElementProperties['markerName']) !== '') {
$markers[\trim($formElemenProperties['markerName'])] = $value; $markers[\trim($formElementProperties['markerName'])] = $value;
} else { } else {
$markers[$identifier] = $value; $markers[$identifier] = $value;
} }
...@@ -94,19 +94,18 @@ class FormsFinisher extends AbstractFinisher { ...@@ -94,19 +94,18 @@ class FormsFinisher extends AbstractFinisher {
$templateName = $formDefinition->getIdentifier(); $templateName = $formDefinition->getIdentifier();
} }
$ignoreMailQueue = (boolean) $this->parseOption('ignoreMailQueue');
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$mailTemplateService = $objectManager->get( $mailTemplateService = $objectManager->get(
MailTemplateService::class, $templateName, 'sg_mail', $markers MailTemplateService::class, $templateName, 'sg_mail', $markers
); );
$ignoreMailQueue = (boolean) $this->parseOption('ignoreMailQueue');
$mailTemplateService->setIgnoreMailQueue($ignoreMailQueue); $mailTemplateService->setIgnoreMailQueue($ignoreMailQueue);
$mailTemplateService->setLanguage($GLOBALS['TSFE']->config['config']['language']); $mailTemplateService->setLanguage($GLOBALS['TSFE']->config['config']['language']);
$mailToAdresses = trim((string) $this->parseOption('mailTo')); $mailToAddresses = trim((string) $this->parseOption('mailTo'));
if ($mailToAdresses !== '') { if ($mailToAddresses !== '') {
$mailTemplateService->setToAddresses($this->parseOption('mailTo')); $mailTemplateService->setToAddresses($mailToAddresses);
} }
$fromAddress = trim((string) $this->parseOption('mailFrom')); $fromAddress = trim((string) $this->parseOption('mailFrom'));
......
...@@ -431,7 +431,9 @@ class BackendService { ...@@ -431,7 +431,9 @@ class BackendService {
} }
// filter out excluded templates from all domains // filter out excluded templates from all domains
if (isset($extensionConfiguration['excludeTemplatesAllDomains']) && $extensionConfiguration['excludeTemplatesAllDomains'] !== '') { if (isset($extensionConfiguration['excludeTemplatesAllDomains']) &&
$extensionConfiguration['excludeTemplatesAllDomains'] !== ''
) {
$excludedTemplates = GeneralUtility::trimExplode( $excludedTemplates = GeneralUtility::trimExplode(
',', $extensionConfiguration['excludeTemplatesAllDomains'], TRUE ',', $extensionConfiguration['excludeTemplatesAllDomains'], TRUE
); );
......
...@@ -62,24 +62,24 @@ class MailTemplateService { ...@@ -62,24 +62,24 @@ class MailTemplateService {
const CONFIG_PATH = 'Configuration/MailTemplates'; const CONFIG_PATH = 'Configuration/MailTemplates';
/** /**
* @var array $toAddresses * @var string $toAddresses
*/ */
private $toAddresses = []; private $toAddresses = '';
/** /**
* @var string $fromAddress * @var string $fromAddress
*/ */
private $fromAddress; private $fromAddress = '';
/** /**
* @var array $ccAddresses * @var string $ccAddresses
*/ */
private $ccAddresses; private $ccAddresses;
/** /**
* @var string $replyToAddress * @var string $replyToAddress
*/ */
private $replyToAddress; private $replyToAddress = '';
/** /**
* @var string $language * @var string $language
...@@ -117,7 +117,7 @@ class MailTemplateService { ...@@ -117,7 +117,7 @@ class MailTemplateService {
private $markers; private $markers;
/** /**
* @var array $bccAddresses * @var string $bccAddresses
*/ */
private $bccAddresses; private $bccAddresses;
...@@ -211,6 +211,254 @@ class MailTemplateService { ...@@ -211,6 +211,254 @@ class MailTemplateService {
} }
} }
/**
* @param string $fromName
*/
public function setFromName($fromName) {
$this->fromName = $fromName;
}
/**
* Provides translation for the marker data type
*
* @param string $markerType
*/
public static function getReadableMarkerType($markerType) {
switch ($markerType) {
case self::MARKER_TYPE_STRING :
LocalizationUtility::translate('backend.marker.type.string', 'sg_mail');
break;
case self::MARKER_TYPE_ARRAY :
LocalizationUtility::translate('backend.marker.type.array', 'sg_mail');
break;
case self::MARKER_TYPE_OBJECT :
LocalizationUtility::translate('backend.marker.type.object', 'sg_mail');
break;
case self::MARKER_TYPE_FILE:
LocalizationUtility::translate('backend.marker.type.file', 'sg_mail');
break;
default:
LocalizationUtility::translate('backend.marker.type.mixed', 'sg_mail');
}
}
/**
* @param string $toAddresses
* @return MailTemplateService
*/
public function setToAddresses($toAddresses): MailTemplateService {
$normalizedToAddresses = trim(preg_replace('~\x{00a0}~iu', ' ', $toAddresses));
$this->toAddresses = $normalizedToAddresses;
$addressesArray = GeneralUtility::trimExplode(',', $normalizedToAddresses, TRUE);
if (\count($addressesArray) > 1) {
$normalizedToAddresses = $addressesArray;
}
$this->mailMessage->setTo($normalizedToAddresses);
return $this;
}
/**
* @param string $fromAddress
* @param string $fromName
* @return MailTemplateService
*/
public function setFromAddress($fromAddress, $fromName = ''): MailTemplateService {
if ($fromAddress) {
$this->fromAddress = $fromAddress;
$this->mailMessage->setFrom($fromAddress, $fromName);
}
return $this;
}
/**
* @param string $ccAddresses
* @return MailTemplateService
*/
public function setCcAddresses($ccAddresses): MailTemplateService {
if ($ccAddresses) {
$this->ccAddresses = $ccAddresses;
$this->mailMessage->setCc(GeneralUtility::trimExplode(',', $this->ccAddresses));
}
return $this;
}
/**
* @param string $replyToAddress
* @return MailTemplateService
*/
public function setReplyToAddress($replyToAddress): MailTemplateService {
if ($replyToAddress) {
$this->replyToAddress = $replyToAddress;
$this->mailMessage->setReplyTo($replyToAddress);
}
return $this;
}
/**
* @param string $language
* @return MailTemplateService
*/
public function setLanguage($language): MailTemplateService {
$this->language = $language;
return $this;
}
/**
* @param boolean $ignoreMailQueue
* @return MailTemplateService
*/
public function setIgnoreMailQueue($ignoreMailQueue): MailTemplateService {
$this->ignoreMailQueue = $ignoreMailQueue;
return $this;
}
/**
* @param string $templateName
* @return MailTemplateService
*/
public function setTemplateName($templateName): MailTemplateService {
$this->templateName = $templateName;
return $this;
}
/**
* @param string $extensionKey
* @return MailTemplateService
*/
public function setExtensionKey($extensionKey): MailTemplateService {
$this->extensionKey = $extensionKey;
return $this;
}
/**
* @param array $markers
* @return MailTemplateService
*/
public function setMarkers(array $markers): MailTemplateService {
$this->markers = $markers;
return $this;
}
/**
* @param string $bccAddresses
* @return MailTemplateService
*/
public function setBccAddresses($bccAddresses): MailTemplateService {
if ($bccAddresses) {
$this->bccAddresses = $bccAddresses;
$this->mailMessage->setBcc(GeneralUtility::trimExplode(',', $this->bccAddresses));
}
return $this;
}
/**
* @param int $priority
* @return MailTemplateService
*/
public function setPriority($priority): MailTemplateService {
$this->priority = $priority;
return $this;
}
/**
* @param Swift_OutputByteStream $data
* @param string $filename
* @param string $contentType
* @return MailTemplateService
*/
public function addAttachment($data, $filename, $contentType): MailTemplateService {
$attachment = Swift_Attachment::newInstance()
->setFilename($filename)
->setContentType($contentType)
->setBody($data);
$this->mailMessage->attach($attachment);
return $this;
}
/**
* Add a file resource as attachment
*
* @param FileInterface|FileReference $file
* @return MailTemplateService
*/
public function addFileResourceAttachment($file): MailTemplateService {
if ($file instanceof FileReference) {
$file = $file->getOriginalResource()->getOriginalFile();
}
$fileReference = $this->objectManager->get(FileReference::class);
$resourceFactory = $this->objectManager->get(ResourceFactory::class);
$falFileReference = $resourceFactory->createFileReferenceObject(
[
'uid_local' => $file->getUid(),
'uid_foreign' => uniqid('NEW_', TRUE),
'uid' => uniqid('NEW_', TRUE),
'crop' => NULL,
]
);
$fileReference->setOriginalResource($falFileReference);
$this->markers[] = $fileReference;
/** @noinspection PhpParamsInspection */
$this->addAttachment($file->getContents(), $file->getName(), $file->getMimeType());
return $this;
}
/**
* @return MailMessage
*/
public function getMailMessage(): MailMessage {
return $this->mailMessage;
}
/**
* set the page id from which this was called
*
* @param int $pid
* @return MailTemplateService
*/
public function setPid($pid): MailTemplateService {
$this->pid = (int) $pid;
return $this;
}
/**
* Checks if a template is blacklisted for a given siteroot id
*
* @param string $extensionKey
* @param string $templateName
* @param int $siteRootId
* @return boolean
* @throws \InvalidArgumentException
* @throws \BadFunctionCallException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public static function isTemplateBlacklisted($extensionKey, $templateName, $siteRootId): bool {
$nonBlacklistedTemplates = BackendService::getNonBlacklistedTemplates($siteRootId);
if ($nonBlacklistedTemplates[$extensionKey]) {
return $nonBlacklistedTemplates[$extensionKey][$templateName] ? FALSE : TRUE;
}
return TRUE;
}
/**
* @return string
*/
public function getSubject(): string {
return $this->subject;
}
/**
* @param string $subject
*/
public function setSubject(string $subject) {
$this->subject = $subject;
}
/** /**
* Return default markers for sg_mail * Return default markers for sg_mail
* *
...@@ -250,14 +498,15 @@ class MailTemplateService { ...@@ -250,14 +498,15 @@ class MailTemplateService {
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws \BadFunctionCallException * @throws \BadFunctionCallException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \Exception
*/ */
public function sendEmail($isPreview = FALSE): bool { public function sendEmail($isPreview = FALSE): bool {
$registerService = GeneralUtility::makeInstance(RegisterService::class); $registerService = GeneralUtility::makeInstance(RegisterService::class);
if (TYPO3_MODE === 'FE') { if (TYPO3_MODE === 'FE') {
/** @var TypoScriptFrontendController $tsfe */ /** @var TypoScriptFrontendController $typoscriptFrontendController */
$tsfe = $GLOBALS['TSFE']; $typoscriptFrontendController = $GLOBALS['TSFE'];
$pageUid = (int) $tsfe->id; $pageUid = (int) $typoscriptFrontendController->id;
} else { } else {
$pageUid = (int) GeneralUtility::_GP('id'); $pageUid = (int) GeneralUtility::_GP('id');
} }
...@@ -349,6 +598,7 @@ class MailTemplateService { ...@@ -349,6 +598,7 @@ class MailTemplateService {
$temporaryMarkerArray = [$markerPathSegment => $temporaryMarkerArray]; $temporaryMarkerArray = [$markerPathSegment => $temporaryMarkerArray];
} }
} }
/** @noinspection SlowArrayOperationsInLoopInspection */
$previewMarker = array_merge_recursive($previewMarker, $temporaryMarkerArray); $previewMarker = array_merge_recursive($previewMarker, $temporaryMarkerArray);
} }
$this->setIgnoreMailQueue(TRUE); $this->setIgnoreMailQueue(TRUE);
...@@ -389,15 +639,16 @@ class MailTemplateService { ...@@ -389,15 +639,16 @@ class MailTemplateService {
$this->mailMessage->setSubject($subject); $this->mailMessage->setSubject($subject);
$emailBody = $emailView->render();
// insert <br /> tags, but replace every instance of three or more successive breaks with just two.
$emailBody = nl2br($emailBody);
$emailBody = preg_replace('/(<br[\s]?[\/]?>[\s]*){3,}/', '<br /><br />', $emailBody);
$isTemplateBlacklisted = self::isTemplateBlacklisted( $isTemplateBlacklisted = self::isTemplateBlacklisted(
$this->extensionKey, $this->templateName, $siteRootId $this->extensionKey, $this->templateName, $siteRootId
); );
// insert <br> tags, but replace every instance of three or more successive breaks with just two.
$emailBody = $emailView->render();
$emailBody = nl2br($emailBody);
$emailBody = preg_replace('/(<br[\s]?[\/]?>[\s]*){3,}/', '<br><br>', $emailBody);
$currentTimestamp = 0;
if ($this->ignoreMailQueue && !$isTemplateBlacklisted) { if ($this->ignoreMailQueue && !$isTemplateBlacklisted) {
$this->mailMessage->setBody($emailBody, 'text/html'); $this->mailMessage->setBody($emailBody, 'text/html');
$plaintextService = GeneralUtility::makeInstance(PlaintextService::class); $plaintextService = GeneralUtility::makeInstance(PlaintextService::class);
...@@ -406,21 +657,13 @@ class MailTemplateService { ...@@ -406,21 +657,13 @@ class MailTemplateService {
$this->mailMessage->send(); $this->mailMessage->send();
$dateTime = new DateTime(); $dateTime = new DateTime();
$currentTimestamp = $dateTime->getTimestamp(); $currentTimestamp = $dateTime->getTimestamp();
}
if (!$isPreview) { if (!$isPreview) {
$this->addMailToMailQueue( $this->addMailToMailQueue(
$this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority, $this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority,
$currentTimestamp, $currentTimestamp, $this->language, $siteRootId $currentTimestamp, $currentTimestamp, $this->language, $siteRootId
); );
}
} else {
if (!$isPreview) {
$this->addMailToMailQueue(
$this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority, 0, 0,
$this->language, $siteRootId
);
}
} }
return TRUE; return TRUE;
...@@ -483,6 +726,7 @@ class MailTemplateService { ...@@ -483,6 +726,7 @@ class MailTemplateService {
* @param int $uid * @param int $uid
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
* @throws \Exception
*/ */
public function sendMailFromQueue($uid) { public function sendMailFromQueue($uid) {
$mailRepository = $this->objectManager->get(MailRepository::class); $mailRepository = $this->objectManager->get(MailRepository::class);
...@@ -536,177 +780,6 @@ class MailTemplateService { ...@@ -536,177 +780,6 @@ class MailTemplateService {
} }
} }
/**
* @param string $toAddresses
* @return MailTemplateService
*/
public function setToAddresses($toAddresses): MailTemplateService {
$toAddresses = trim(preg_replace('~\x{00a0}~siu', ' ', $toAddresses));
$this->toAddresses = $toAddresses;
$addressesArray = GeneralUtility::trimExplode(',', $toAddresses, TRUE);
if (\count($addressesArray) > 1) {
$toAddresses = $addressesArray;
}
$this->mailMessage->setTo($toAddresses);
return $this;
}
/**
* @param string $fromAddress
* @param string $fromName
* @return MailTemplateService
*/
public function setFromAddress($fromAddress, $fromName = ''): MailTemplateService {
if ($fromAddress) {
$this->fromAddress = $fromAddress;
$this->mailMessage->setFrom($fromAddress, $fromName);
}
return $this;
}
/**
* @param string $ccAddresses
* @return MailTemplateService
*/
public function setCcAddresses($ccAddresses): MailTemplateService {
if ($ccAddresses) {
$this->ccAddresses = $ccAddresses;
$this->mailMessage->setCc(GeneralUtility::trimExplode(',', $this->ccAddresses));
}
return $this;
}
/**
* @param string $replyToAddress
* @return MailTemplateService
*/
public function setReplyToAddress($replyToAddress): MailTemplateService {
if ($replyToAddress) {
$this->replyToAddress = $replyToAddress;
$this->mailMessage->setReplyTo($replyToAddress);
}
return $this;
}
/**
* @param string $language
* @return MailTemplateService
*/
public function setLanguage($language): MailTemplateService {
$this->language = $language;
return $this;
}
/**
* @param boolean $ignoreMailQueue
* @return MailTemplateService
*/
public function setIgnoreMailQueue($ignoreMailQueue): MailTemplateService {
$this->ignoreMailQueue = $ignoreMailQueue;
return $this;
}
/**
* @param string $templateName
* @return MailTemplateService
*/
public function setTemplateName($templateName): MailTemplateService {
$this->templateName = $templateName;
return $this;
}
/**
* @param string $extensionKey
* @return MailTemplateService
*/
public function setExtensionKey($extensionKey): MailTemplateService {
$this->extensionKey = $extensionKey;
return $this;
}
/**
* @param array $markers
* @return MailTemplateService
*/
public function setMarkers(array $markers): MailTemplateService {
$this->markers = $markers;
return $this;
}
/**
* @param string $bccAddresses
* @return MailTemplateService
*/
public function setBccAddresses($bccAddresses): MailTemplateService {
if ($bccAddresses) {
$this->bccAddresses = $bccAddresses;
$this->mailMessage->setBcc(GeneralUtility::trimExplode(',', $this->bccAddresses));
}
return $this;
}
/**
* @param int $priority
* @return MailTemplateService
*/
public function setPriority($priority): MailTemplateService {
$this->priority = $priority;
return $this;
}
/**
* @param Swift_OutputByteStream $data
* @param string $filename
* @param string $contentType
* @return MailTemplateService
*/
public function addAttachment($data, $filename, $contentType): MailTemplateService {
$attachment = Swift_Attachment::newInstance()
->setFilename($filename)
->setContentType($contentType)
->setBody($data);
$this->mailMessage->attach($attachment);
return $this;
}
/**
* Add a file resource as attachment
*
* @param FileInterface|FileReference $file
* @return MailTemplateService
*/
public function addFileResourceAttachment($file): MailTemplateService {
if ($file instanceof FileReference) {
$file = $file->getOriginalResource()->getOriginalFile();
}
$fileReference = $this->objectManager->get(FileReference::class);
$resourceFactory = $this->objectManager->get(ResourceFactory::class);
$falFileReference = $resourceFactory->createFileReferenceObject(
[
'uid_local' => $file->getUid(),
'uid_foreign' => uniqid('NEW_', TRUE),
'uid' => uniqid('NEW_', TRUE),
'crop' => NULL,
]
);
$fileReference->setOriginalResource($falFileReference);
$this->markers[] = $fileReference;
$this->addAttachment($file->getContents(), $file->getName(), $file->getMimeType());
return $this;
}
/**
* @return MailMessage
*/
public function getMailMessage(): MailMessage {
return $this->mailMessage;
}
/** /**
* use all values from the given template * use all values from the given template
* *
...@@ -734,48 +807,6 @@ class MailTemplateService { ...@@ -734,48 +807,6 @@ class MailTemplateService {
$this->setReplyToAddress($template->getReplyTo()); $this->setReplyToAddress($template->getReplyTo());
} }
/**
* @param string $fromName
*/
public function setFromName($fromName) {
$this->fromName = $fromName;
}
/**
* Provides translation for the marker data type
*
* @param string $markerType
*/
public static function getReadableMarkerType($markerType) {
switch ($markerType) {
case self::MARKER_TYPE_STRING :
LocalizationUtility::translate('backend.marker.type.string', 'sg_mail');
break;
case self::MARKER_TYPE_ARRAY :
LocalizationUtility::translate('backend.marker.type.array', 'sg_mail');
break;
case self::MARKER_TYPE_OBJECT :
LocalizationUtility::translate('backend.marker.type.object', 'sg_mail');
break;
case self::MARKER_TYPE_FILE:
LocalizationUtility::translate('backend.marker.type.file', 'sg_mail');
break;
default:
LocalizationUtility::translate('backend.marker.type.mixed', 'sg_mail');
}
}
/**
* set the page id from which this was called
*
* @param int $pid
* @return MailTemplateService
*/
public function setPid($pid): MailTemplateService {
$this->pid = (int) $pid;
return $this;
}
/** /**
* Get all registered templates * Get all registered templates
* *
...@@ -827,41 +858,6 @@ class MailTemplateService { ...@@ -827,41 +858,6 @@ class MailTemplateService {
} }
} }
/**
* Checks if a template is blacklisted for a given siteroot id
*
* @param string $extensionKey
* @param string $templateName
* @param int $siteRootId
* @return boolean
* @throws \InvalidArgumentException
* @throws \BadFunctionCallException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public static function isTemplateBlacklisted($extensionKey, $templateName, $siteRootId): bool {
$nonBlacklistedTemplates = BackendService::getNonBlacklistedTemplates($siteRootId);
if ($nonBlacklistedTemplates[$extensionKey]) {
return $nonBlacklistedTemplates[$extensionKey][$templateName] ? FALSE : TRUE;
}
return TRUE;
}
/**
* @return string
*/
public function getSubject(): string {
return $this->subject;
}
/**
* @param string $subject
*/
public function setSubject(string $subject) {
$this->subject = $subject;
}
/** /**
* Get a single variable containing a list of all markers * Get a single variable containing a list of all markers
* *
......
...@@ -97,7 +97,7 @@ class PlaintextService ...@@ -97,7 +97,7 @@ class PlaintextService
} }
/** /**
* add linebreaks on some parts (</p> => </p><br />) * add linebreaks on some parts (</p> => </p><br>)
* *
* @param string $content * @param string $content
* @return array * @return array
...@@ -121,7 +121,7 @@ class PlaintextService ...@@ -121,7 +121,7 @@ class PlaintextService
'</dd>', '</dd>',
'</dt>' '</dt>'
]; ];
return str_replace($tags2LineBreaks, '</p><br />', $content); return str_replace($tags2LineBreaks, '</p><br>', $content);
} }
/** /**
......
...@@ -29,12 +29,9 @@ use SGalinski\SgMail\Service\MailTemplateService; ...@@ -29,12 +29,9 @@ use SGalinski\SgMail\Service\MailTemplateService;
use SGalinski\SgMail\Service\RegisterService; use SGalinski\SgMail\Service\RegisterService;
use SGalinski\SgMail\Service\TypoScriptSettingsService; use SGalinski\SgMail\Service\TypoScriptSettingsService;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Resource\ResourceStorage; use TYPO3\CMS\Core\Resource\ResourceStorage;
use TYPO3\CMS\Core\Resource\StorageRepository; use TYPO3\CMS\Core\Resource\StorageRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Form\Type\FormDefinitionArray; use TYPO3\CMS\Form\Type\FormDefinitionArray;
/** @noinspection LongInheritanceChainInspection */ /** @noinspection LongInheritanceChainInspection */
...@@ -71,7 +68,6 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll ...@@ -71,7 +68,6 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/ */
public function saveFormAction(string $formPersistenceIdentifier, FormDefinitionArray $formDefinition) { public function saveFormAction(string $formPersistenceIdentifier, FormDefinitionArray $formDefinition) {
$registrationService = $this->objectManager->get(RegisterService::class); $registrationService = $this->objectManager->get(RegisterService::class);
/** @noinspection PhpInternalEntityUsedInspection */ /** @noinspection PhpInternalEntityUsedInspection */
parent::saveFormAction($formPersistenceIdentifier, $formDefinition); parent::saveFormAction($formPersistenceIdentifier, $formDefinition);
...@@ -83,9 +79,7 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll ...@@ -83,9 +79,7 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
/** @var array $finishers */ /** @var array $finishers */
$finishers = $formDefinition['finishers']; $finishers = $formDefinition['finishers'];
foreach ($finishers as $finisher) { foreach ($finishers as $finisher) {
// if the current finisher prevents automatic registration, exit this iteration // if the current finisher prevents automatic registration, exit this iteration
if (!$finisher['options']['automaticRegistration']) { if (!$finisher['options']['automaticRegistration']) {
continue; continue;
...@@ -96,7 +90,8 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll ...@@ -96,7 +90,8 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
} }
// retrieve the extension and template key and jump out of loop // retrieve the extension and template key and jump out of loop
$extensionKey = $finisher['options']['extension']; $extensionKey = (string) $finisher['options']['extension'];
$extensionKey = $extensionKey ?: 'sg_mail';
$templateKey = str_replace('_', '-', $finisher['options']['template']); $templateKey = str_replace('_', '-', $finisher['options']['template']);
// if no template key was explicitly set, use the form identifier as template key // if no template key was explicitly set, use the form identifier as template key
...@@ -105,8 +100,8 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll ...@@ -105,8 +100,8 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
} }
// if there was no sg mail finisher or an missing key then simply exit the function // if there was no sg mail finisher or an missing key then simply exit the function
if ($extensionKey === '' || $templateKey === '') { if ($templateKey === '') {
return; throw new \InvalidArgumentException(sprintf('Missing template or extension key!'));
} }
// parse yaml for form fields // parse yaml for form fields
...@@ -210,21 +205,6 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll ...@@ -210,21 +205,6 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
return $registerFile; return $registerFile;
} }
/**
* Clear the sgmail register cache
*
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
private function clearCaches() {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$cacheManager = $objectManager->get(CacheManager::class);
/** @var FrontendInterface $cache */
$cache = $cacheManager->getCache(RegisterService::CACHE_NAME);
/** @var FrontendInterface $cache */
$cache->flush();
}
/** /**
* Returns the path to the configured location where automatic mail template registrations should be * Returns the path to the configured location where automatic mail template registrations should be
* *
......
...@@ -66,8 +66,8 @@ ...@@ -66,8 +66,8 @@
<target><![CDATA[Beschreibung]]></target> <target><![CDATA[Beschreibung]]></target>
</trans-unit> </trans-unit>
<trans-unit id="backend.create.info" approved="yes"> <trans-unit id="backend.create.info" approved="yes">
<source><![CDATA[Please insert the template marker in the following format: markerName; exampleValue; description <br /><br />Whitespaces in marker names are ignored. <br />If you have multiple markers, seperate them with a new line: markerName1; exampleValue1; description1<br />markerName2; exampleValue2; description2 <br /><br />Example: first_name; Max; The first name of the client <br />last_name; Mustermann; The last name of the client]]></source> <source><![CDATA[Please insert the template marker in the following format: markerName; exampleValue; description <br><br>Whitespaces in marker names are ignored. <br />If you have multiple markers, seperate them with a new line: markerName1; exampleValue1; description1<br />markerName2; exampleValue2; description2 <br /><br />Example: first_name; Max; The first name of the client <br />last_name; Mustermann; The last name of the client]]></source>
<target><![CDATA[Bitte geben Sie die Template Marker im folgenden Format ein: markerName; beispiel; beschreibung <br /><br />Leerzeichen in Markernamen werden ignoriert. <br /><br />Mehrere Marker werden mit der Eingabetaste getrennt: markerName1; beispiel1; beschreibung1<br />markerName2; beispiel2; beschreibung2 <br /><br />Beispiel: first_name; Max; Der Vorname des Kunden<br /> last_name; Mustermann; Der Nachname des Kunden]]></target> <target><![CDATA[Bitte geben Sie die Template Marker im folgenden Format ein: markerName; beispiel; beschreibung <br><br>Leerzeichen in Markernamen werden ignoriert. <br /><br />Mehrere Marker werden mit der Eingabetaste getrennt: markerName1; beispiel1; beschreibung1<br />markerName2; beispiel2; beschreibung2 <br /><br />Beispiel: first_name; Max; Der Vorname des Kunden<br /> last_name; Mustermann; Der Nachname des Kunden]]></target>
</trans-unit> </trans-unit>
<trans-unit id="backend.create.info_header" approved="yes"> <trans-unit id="backend.create.info_header" approved="yes">
<source><![CDATA[Usage Information]]></source> <source><![CDATA[Usage Information]]></source>
......
...@@ -65,7 +65,7 @@ Please register your configurations in the according ext_localconf.php.]]></sour ...@@ -65,7 +65,7 @@ Please register your configurations in the according ext_localconf.php.]]></sour
<source><![CDATA[Description]]></source> <source><![CDATA[Description]]></source>
</trans-unit> </trans-unit>
<trans-unit id="backend.create.info"> <trans-unit id="backend.create.info">
<source><![CDATA[Please insert the template marker in the following format: markerName; exampleValue; description <br /><br />Whitespaces in marker names are ignored. <br />If you have multiple markers, seperate them with a new line: markerName1; exampleValue1; description1<br />markerName2; exampleValue2; description2 <br /><br />Example: first_name; Max; The first name of the client <br />last_name; Mustermann; The last name of the client]]></source> <source><![CDATA[Please insert the template marker in the following format: markerName; exampleValue; description <br><br>Whitespaces in marker names are ignored. <br />If you have multiple markers, seperate them with a new line: markerName1; exampleValue1; description1<br />markerName2; exampleValue2; description2 <br /><br />Example: first_name; Max; The first name of the client <br />last_name; Mustermann; The last name of the client]]></source>
</trans-unit> </trans-unit>
<trans-unit id="backend.create.info_header"> <trans-unit id="backend.create.info_header">
<source><![CDATA[Usage Information]]></source> <source><![CDATA[Usage Information]]></source>
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<f:then> <f:then>
<f:for each="{marker.value}" as="value" key="key"> <f:for each="{marker.value}" as="value" key="key">
{key}: {value} {key}: {value}
<br /> <br>
</f:for> </f:for>
</f:then> </f:then>
<f:else> <f:else>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment