diff --git a/Classes/Controller/ConfigurationController.php b/Classes/Controller/ConfigurationController.php index 29ac47220740ee9ed5d29a2ea83da892356204af..61a7b3f521d72a72a0d111196e03320f7c2e89df 100644 --- a/Classes/Controller/ConfigurationController.php +++ b/Classes/Controller/ConfigurationController.php @@ -110,63 +110,64 @@ class ConfigurationController extends ActionController { * * @throws StopActionException * @throws UnsupportedRequestTypeException + * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException */ public function createAction() { - try { - /** @var array $configuration */ - $configuration = $this->request->getArgument('configuration'); - - $templateName = $configuration['templateName']; - $csv = $configuration['csv']; - $subject = $configuration['subject']; - $description = $configuration['description']; - - // parse csv (,,,;,,,;) - $markersCsv = str_getcsv($csv, ';'); - $markers = []; - - foreach ($markersCsv as $markerCsv) { - $rowArray = GeneralUtility::trimExplode(',', $markerCsv); - $markers[] = [ - 'identifier' => $rowArray[0], - 'value' => $rowArray[1], - 'description' => $rowArray[2] - ]; - } + if (!$this->$this->request->hasArgument('configuration')) { + $this->redirect( + 'index', 'Configuration', NULL, + ['message' => LocalizationUtility::translate('backend.create_error', 'sg_mail')] + ); + } - // write the new Register.php file - $this->writeRegisterFile($templateName, self::DEFAULT_EXTENSION_KEY, $markers, $subject, $description); + /** @var array $configuration */ + $configuration = $this->request->getArgument('configuration'); - // call register function in mail template service class - MailTemplateService::registerExtensions(); + $templateName = $configuration['templateName']; + $csv = $configuration['csv']; + $subject = $configuration['subject']; + $description = $configuration['description']; - // clear caches - $this->clearCaches(); + // parse csv (,,,;,,,;) + $markersCsv = str_getcsv($csv, ';'); + $markers = []; - // store selected template & extension key in the session - if (!($this->session instanceof PhpSession)) { - $this->session = $this->objectManager->get(PhpSession::class); - $this->session->setSessionKey('sg_mail_controller_session'); - } else { - $this->session->setSessionKey('sg_mail_controller_session'); + foreach ($markersCsv as $markerCsv) { + $rowArray = GeneralUtility::trimExplode(',', $markerCsv); + if (!$rowArray[0]) { + continue; } - $this->session->setDataByKey('selectedTemplate', $templateName); - $this->session->setDataByKey('selectedExtension', self::DEFAULT_EXTENSION_KEY); + $markers[] = [ + 'identifier' => $rowArray[0], + 'value' => $rowArray[1], + 'description' => $rowArray[2] + ]; + } - $this->redirect( - 'index', 'Mail', NULL, - ['message' => LocalizationUtility::translate('backend.create_message', 'sg_mail')] - ); + // write the new Register.php file + $this->writeRegisterFile($templateName, self::DEFAULT_EXTENSION_KEY, $markers, $subject, $description); - } catch (\Exception $e) { - $logger = GeneralUtility::makeInstance(Logger::class, ['name' => 'sgmail_error_logger']); - $logger->error($e->getMessage()); + // call register function in mail template service class + MailTemplateService::registerExtensions(); - $this->redirect( - 'index', 'Configuration', NULL, - ['message' => LocalizationUtility::translate('backend.create_error', 'sg_mail')] - ); + // clear caches + $this->clearCaches(); + + // store selected template & extension key in the session + if (!($this->session instanceof PhpSession)) { + $this->session = $this->objectManager->get(PhpSession::class); + $this->session->setSessionKey('sg_mail_controller_session'); + } else { + $this->session->setSessionKey('sg_mail_controller_session'); } + $this->session->setDataByKey('selectedTemplate', $templateName); + $this->session->setDataByKey('selectedExtension', self::DEFAULT_EXTENSION_KEY); + + $this->redirect( + 'index', 'Mail', NULL, + ['message' => LocalizationUtility::translate('backend.create_message', 'sg_mail')] + ); } /** diff --git a/Resources/Private/Templates/Mail/Index.html b/Resources/Private/Templates/Mail/Index.html index cf8b315daba633eff10906a1be93fca2bccb0597..8be2fecbdde0a2928a2e683dc609bfb2e51391df 100644 --- a/Resources/Private/Templates/Mail/Index.html +++ b/Resources/Private/Templates/Mail/Index.html @@ -53,12 +53,16 @@ </f:for> </f:then> <f:else> - <f:translate key="{marker.value}">{marker.value}</f:translate> + <f:if condition="{marker.value}"> + <f:translate key="{marker.value}">{marker.value}</f:translate> + </f:if> </f:else> </f:if> </td> <td> - <f:translate key="{marker.description}">{marker.description}</f:translate> + <f:if condition="{marker.description}"> + <f:translate key="{marker.description}">{marker.description}</f:translate> + </f:if> </td> </tr> </f:for>