Commit 0a2f68e1 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Refactoring some code, exception handling

parent 15859bab
......@@ -71,14 +71,14 @@ class MailController extends ActionController {
* @param string $selectedExtension
* @param string $selectedLanguageLeft
* @param string $selectedLanguageRight
* @param string $selectedExtensionKey
* @param string $selectedTemplateKey
* @throws \InvalidArgumentException
* @throws \UnexpectedValueException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
public function indexAction(
$selectedTemplate = NULL, $selectedExtension = NULL, $selectedLanguageLeft = NULL,
$selectedLanguageRight = NULL, $selectedExtensionKey = NULL, $selectedTemplateKey = NULL
$selectedLanguageRight = NULL
) {
$siteRoot = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$siteRootId = $siteRoot['uid'];
......@@ -106,20 +106,24 @@ class MailController extends ActionController {
// get last selected languages
if ($selectedLanguageLeft === NULL) {
$selectedLanguageLeft = $this->session->getDataByKey('selectedLanguageLeft');
if ($selectedLanguageLeft === NULL) {
$selectedLanguageLeftFromSession = $this->session->getDataByKey('selectedLanguageLeft');
if ($selectedLanguageLeftFromSession=== NULL) {
$selectedLanguageLeft = $languages[0];
} else {
$selectedLanguageLeft = $selectedLanguageLeftFromSession;
}
}
if ($selectedLanguageRight === NULL) {
$selectedLanguageRight = $this->session->getDataByKey('selectedLanguageRight');
if ($selectedLanguageRight === NULL) {
$selectedLanguageRightFromSession = $this->session->getDataByKey('selectedLanguageRight');
if ($selectedLanguageRightFromSession === NULL) {
if (isset($languages[1])) {
$selectedLanguageRight = $languages[1];
} else {
$selectedLanguageRight = $languages[0];
}
} else {
$selectedLanguageRight = $selectedLanguageRightFromSession;
}
}
......@@ -184,12 +188,10 @@ class MailController extends ActionController {
$langFile = GeneralUtility::readLLfile(
'EXT:' . $selectedExtension . '/Resources/Private/Language/locallang.xlf', $selectedLanguageLeft
);
$translatedSubject = '';
$translatedSubject = $langFile['default'][$subject][0]['target'];
if ($langFile[$selectedLanguageLeft][$subject][0]) {
$translatedSubject = $langFile[$selectedLanguageLeft][$subject][0]['target'];
} else {
$translatedSubject = $langFile['default'][$subject][0]['target'];
}
$this->view->assign(
......@@ -200,12 +202,10 @@ class MailController extends ActionController {
$langFile = GeneralUtility::readLLfile(
'EXT:' . $selectedExtension . '/Resources/Private/Language/locallang.xlf', $selectedLanguageRight
);
$translatedSubject = '';
$translatedSubject = $langFile['default'][$subject][0]['target'];
if ($langFile[$selectedLanguageLeft][$subject][0][$subject]) {
$translatedSubject = $langFile[$selectedLanguageRight][$subject][0]['target'];
} else {
$translatedSubject = $langFile['default'][$subject][0]['target'];
}
$this->view->assign(
......@@ -272,6 +272,11 @@ class MailController extends ActionController {
* @param string $ccRight
* @param string $bccRight
* @param string $replyToRight
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
public function saveAction(
$contentLeft = NULL, $contentRight = NULL, $selectedExtension = NULL, $selectedTemplate = NULL,
......@@ -310,6 +315,9 @@ class MailController extends ActionController {
* @param string $selectedBcc
* @param string $selectedReplyTo
* @return Template $template
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
*/
private function saveTemplate(
$selectedExtension, $selectedTemplate, $selectedLanguage, $selectedContent, $selectedSubject,
......@@ -360,6 +368,10 @@ class MailController extends ActionController {
* @param string $selectedExtensionKey
* @param string $selectedLanguageLeft
* @param string $selectedLanguageRight
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
public function sendTestMailAction(
$emailAddress, $selectedExtensionKey, $selectedTemplateKey, $selectedLanguageLeft, $selectedLanguageRight
......@@ -410,6 +422,9 @@ class MailController extends ActionController {
* @param string $template
* @param string $extensionKey
* @param string $language
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
public function resetAction($template, $extensionKey, $language = '') {
$this->templateRepository->deleteTemplate($extensionKey, $template, $language);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment