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

[TASK] Some code / cgl fixes

parent 9b8b03fd
No related branches found
No related tags found
1 merge request!1Feature sg mail
......@@ -43,7 +43,7 @@ class MailController extends ActionController {
protected $languageRepository = NULL;
/**
* @todo Code-Dokumentation
* Show template Selection and enable content input + mail preview
*
* @param string $selectedTemplate
* @param string $selectedExtension
......@@ -74,8 +74,6 @@ class MailController extends ActionController {
$this->view->assign('languages', $languages);
$this->view->assign('templates', MailTemplateService::getRegisterArray());
// @todo Code-Formattierung. Keine new lines am Anfang und am Ende einer if-Bedingung
if (isset($selectedTemplate)
&& !isset($selectedLanguageLeft)
&& !isset($selectedLanguageRight)
......@@ -89,10 +87,12 @@ class MailController extends ActionController {
} elseif (!isset($selectedLanguageLeft) && !isset($selectedLanguageRight)) {
$this->view->assign(
// @todo Könnte ein Fehler schmeißen, wenn der Wert nicht existiert. Bin mir nicht sicher, besser isset() nutzen
'selectedTemplate', MailTemplateService::getRegisterArray()[$firstEntry][$secondLevelFirstEntry]
);
if (isset(MailTemplateService::getRegisterArray()[$firstEntry][$secondLevelFirstEntry])) {
$this->view->assign(
'selectedTemplate', MailTemplateService::getRegisterArray()[$firstEntry][$secondLevelFirstEntry]
);
}
$this->view->assign('selectedTemplateKey', $secondLevelFirstEntry);
$this->view->assign('selectedExtensionKey', $firstEntry);
}
......@@ -127,7 +127,6 @@ class MailController extends ActionController {
}
/**
* @todo Code-Dokumentation, unklar, bzw. falsch Beschrieben
*
* creates a language File for this Template
*
......@@ -137,29 +136,28 @@ class MailController extends ActionController {
private function writeLanguageFile(\TYPO3\CMS\Lang\Domain\Model\Language $language, $path) {
$currentLangFile = $path . $language->getLocale() . '.sg_mail.locallang.html';
// @todo Wir machen early returns, so haben wir keine große Verschachtlung
if (!file_exists($currentLangFile)) {
$langFileContent = 'TEST: ' . $language->getLocale();
file_put_contents($currentLangFile, $langFileContent);
if (file_exists($currentLangFile)) {
return;
}
$langFileContent = 'TEST: ' . $language->getLocale();
file_put_contents($currentLangFile, $langFileContent);
}
/**
* Save content (left & right)
* if left & right is the same language, the right content will apply
* @todo Ungenutzter Parameter
*
* @param string $contentLeft
* @param string $contentRight
* @param string $selectedExtension
* @param string $selectedTemplate
* @param string $extensionKey
* @param string $selectedLanguageLeft
* @param string $selectedLanguageRight
*/
public function saveAction(
$contentLeft = NULL, $contentRight = NULL, $selectedExtension = NULL, $selectedTemplate = NULL,
$extensionKey = NULL, $selectedLanguageLeft = NULL, $selectedLanguageRight = NULL
$selectedLanguageLeft = NULL, $selectedLanguageRight = NULL
) {
$templatePath = $this->getTemplatePath($selectedExtension, $selectedTemplate);
......@@ -170,8 +168,7 @@ class MailController extends ActionController {
$filename = $templatePath . $selectedLanguageRight . '.sg_mail.locallang.html';
file_put_contents($filename, $contentRight);
// @todo SgMail -> sg_mail | Evtl. kein Fehler, da TYPO3 das für dich macht :)
$message = LocalizationUtility::translate('backend.success', 'SgMail');
$message = LocalizationUtility::translate('backend.success', 'sg_mail');
$this->addFlashMessage($message, '', FlashMessage::OK);
$arguments = $this->request->getArguments();
......@@ -202,34 +199,33 @@ class MailController extends ActionController {
}
/**
* @todo Rechtschreibung, Parameter vergessen bei param
*
* send a test email to a given address
* redirect to index action
*
* @param string $emailAddress
* @param string $templateKey
* @param string $extensionKey
* @param string $languageLeft
* @param string $languageRight
* @param string $selectedTemplateKey
* @param string $selectedExtensionKey
* @param string $selectedLanguageLeft
* @param string $selectedLanguageRight
*/
public function sendTestMailAction(
$emailAddress = NULL, $selectedExtensionKey = NULL, $selectedTemplateKey = NULL, $selectedLanguageLeft = NULL,
$selectedLanguageRight = NULL
) {
// @todo Die "From email" sollte eine TypoScript-Konfiguration sein.
MailTemplateService::sendEmail(
$selectedLanguageLeft, $selectedTemplateKey, $selectedExtensionKey, $emailAddress, 'test@sgmail.de',
$selectedLanguageLeft, $selectedTemplateKey, $selectedExtensionKey, $emailAddress,
$this->settings['mail']['from']['test'],
'This is just a Test E-Mail', [], TRUE
);
MailTemplateService::sendEmail(
$selectedLanguageRight, $selectedTemplateKey, $selectedExtensionKey, $emailAddress, 'test@sgmail.de',
$selectedLanguageRight, $selectedTemplateKey, $selectedExtensionKey, $emailAddress,
$this->settings['mail']['from']['test'],
'This is just a Test E-Mail', [], TRUE
);
// @todo SgMail -> sg_mail | Evtl. kein Fehler, da TYPO3 das für dich macht :)
$message = LocalizationUtility::translate('backend.success_mail', 'SgMail');
$message = LocalizationUtility::translate('backend.success_mail', 'sg_mail');
$this->addFlashMessage($message, '', FlashMessage::OK);
$arguments = $this->request->getArguments();
......
......@@ -6,4 +6,8 @@ plugin.tx_sgcmail {
layoutRootPath = EXT:sg_mail/Resources/Private/Layouts/
publicRootPath = EXT:sg_mail/Resources/Public/
}
mail {
from.test = 'info@test.de'
}
}
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