Skip to content
Snippets Groups Projects
Commit 26c246d1 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Fixing a bug in error handling and display of empty values

parent e9e3a3b0
No related branches found
No related tags found
1 merge request!12Feature backend config
...@@ -110,63 +110,64 @@ class ConfigurationController extends ActionController { ...@@ -110,63 +110,64 @@ class ConfigurationController extends ActionController {
* *
* @throws StopActionException * @throws StopActionException
* @throws UnsupportedRequestTypeException * @throws UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/ */
public function createAction() { public function createAction() {
try { if (!$this->$this->request->hasArgument('configuration')) {
/** @var array $configuration */ $this->redirect(
$configuration = $this->request->getArgument('configuration'); 'index', 'Configuration', NULL,
['message' => LocalizationUtility::translate('backend.create_error', 'sg_mail')]
$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]
];
}
// write the new Register.php file /** @var array $configuration */
$this->writeRegisterFile($templateName, self::DEFAULT_EXTENSION_KEY, $markers, $subject, $description); $configuration = $this->request->getArgument('configuration');
// call register function in mail template service class $templateName = $configuration['templateName'];
MailTemplateService::registerExtensions(); $csv = $configuration['csv'];
$subject = $configuration['subject'];
$description = $configuration['description'];
// clear caches // parse csv (,,,;,,,;)
$this->clearCaches(); $markersCsv = str_getcsv($csv, ';');
$markers = [];
// store selected template & extension key in the session foreach ($markersCsv as $markerCsv) {
if (!($this->session instanceof PhpSession)) { $rowArray = GeneralUtility::trimExplode(',', $markerCsv);
$this->session = $this->objectManager->get(PhpSession::class); if (!$rowArray[0]) {
$this->session->setSessionKey('sg_mail_controller_session'); continue;
} else {
$this->session->setSessionKey('sg_mail_controller_session');
} }
$this->session->setDataByKey('selectedTemplate', $templateName); $markers[] = [
$this->session->setDataByKey('selectedExtension', self::DEFAULT_EXTENSION_KEY); 'identifier' => $rowArray[0],
'value' => $rowArray[1],
'description' => $rowArray[2]
];
}
$this->redirect( // write the new Register.php file
'index', 'Mail', NULL, $this->writeRegisterFile($templateName, self::DEFAULT_EXTENSION_KEY, $markers, $subject, $description);
['message' => LocalizationUtility::translate('backend.create_message', 'sg_mail')]
);
} catch (\Exception $e) { // call register function in mail template service class
$logger = GeneralUtility::makeInstance(Logger::class, ['name' => 'sgmail_error_logger']); MailTemplateService::registerExtensions();
$logger->error($e->getMessage());
$this->redirect( // clear caches
'index', 'Configuration', NULL, $this->clearCaches();
['message' => LocalizationUtility::translate('backend.create_error', 'sg_mail')]
); // 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')]
);
} }
/** /**
......
...@@ -53,12 +53,16 @@ ...@@ -53,12 +53,16 @@
</f:for> </f:for>
</f:then> </f:then>
<f:else> <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:else>
</f:if> </f:if>
</td> </td>
<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> </td>
</tr> </tr>
</f:for> </f:for>
......
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