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 {
*
* @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')]
);
}
/**
......
......@@ -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>
......
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