Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
TYPO3
sg_mail
Commits
c99ab6d6
Commit
c99ab6d6
authored
Sep 20, 2016
by
Fabian Galinski
😾
Browse files
[TASK] Code review
parent
e6013e35
Changes
4
Hide whitespace changes
Inline
Side-by-side
Classes/Controller/MailController.php
View file @
c99ab6d6
...
...
@@ -43,6 +43,8 @@ class MailController extends ActionController {
protected
$languageRepository
=
NULL
;
/**
* @todo Code-Dokumentation
*
* @param string $selectedTemplate
* @param string $selectedExtension
* @param string $selectedLanguageLeft
...
...
@@ -72,6 +74,8 @@ 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
)
...
...
@@ -86,6 +90,7 @@ 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
]
);
$this
->
view
->
assign
(
'selectedTemplateKey'
,
$secondLevelFirstEntry
);
...
...
@@ -122,6 +127,8 @@ class MailController extends ActionController {
}
/**
* @todo Code-Dokumentation, unklar, bzw. falsch Beschrieben
*
* creates a language File for this Template
*
* @param \TYPO3\CMS\Lang\Domain\Model\Language $language
...
...
@@ -129,6 +136,8 @@ 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
);
...
...
@@ -138,6 +147,7 @@ class MailController extends ActionController {
/**
* 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
...
...
@@ -160,6 +170,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'
);
$this
->
addFlashMessage
(
$message
,
''
,
FlashMessage
::
OK
);
...
...
@@ -191,6 +202,8 @@ class MailController extends ActionController {
}
/**
* @todo Rechtschreibung, Parameter vergessen bei param
*
* send a test email to a given address
* redirect to index action
*
...
...
@@ -204,7 +217,7 @@ class MailController extends ActionController {
$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'
,
'This is just a Test E-Mail'
...
...
@@ -215,6 +228,7 @@ class MailController extends ActionController {
'This is just a Test E-Mail'
);
// @todo SgMail -> sg_mail | Evtl. kein Fehler, da TYPO3 das für dich macht :)
$message
=
LocalizationUtility
::
translate
(
'backend.success_mail'
,
'SgMail'
);
$this
->
addFlashMessage
(
$message
,
''
,
FlashMessage
::
OK
);
...
...
Classes/Service/MailTemplateService.php
View file @
c99ab6d6
...
...
@@ -40,6 +40,8 @@ class MailTemplateService {
private
static
$registerArray
=
[];
/**
* @todo Code-Dokumentation, Parameter vergessen bei param
*
* @param string $extension
* @param string $extensionKey
* @param string $template
...
...
@@ -64,6 +66,8 @@ class MailTemplateService {
}
/**
* @todo Code-Dokumentation
*
* @return array
*/
public
static
function
getRegisterArray
()
{
...
...
@@ -71,6 +75,8 @@ class MailTemplateService {
}
/**
* @todo Code-Dokumentation, Parameter vergessen bei param
*
* @param string $language
* @param string $templateKey
* @param string $extensionKey
...
...
@@ -87,6 +93,7 @@ class MailTemplateService {
$templateEntry
=
$registerArray
[
$extensionKey
][
$templateKey
];
$objectManager
=
GeneralUtility
::
makeInstance
(
ObjectManager
::
class
);
// @todo verwende bitte StandaloneView::class
$emailView
=
$objectManager
->
get
(
'TYPO3\\CMS\\Fluid\\View\\StandaloneView'
);
$emailView
->
setTemplatePathAndFilename
(
$templateEntry
[
'templatePath'
]
.
$language
.
'.sg_mail.locallang.html'
);
$emailView
->
assignMultiple
(
$content
);
...
...
Configuration/TypoScript/constants.ts
View file @
c99ab6d6
// @todo Warum sgcmail? Glaube das dies dadurch aktuell nicht genutzt wird. Normal ohne "c"
plugin
.
tx_sgcmail
{
view
{
templateRootPath
=
EXT
:
sg_mail
/
Resources
/
Private
/
Templates
/
...
...
Configuration/TypoScript/setup.ts
View file @
c99ab6d6
// @todo Warum sgcmail? Glaube das dies dadurch aktuell nicht genutzt wird. Normal ohne "c"
module
.
tx_sgcmail
{
view
{
templateRootPath
=
{
$plugin
.
tx_sgcmail
.
view
.
templateRootPath
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment