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
0575cc2a
Commit
0575cc2a
authored
Oct 03, 2016
by
Torsten Oppermann
Browse files
[TASK] Restoring default template fallback
parent
3c7b3594
Changes
1
Hide whitespace changes
Inline
Side-by-side
Classes/Service/MailTemplateService.php
View file @
0575cc2a
...
...
@@ -170,9 +170,10 @@ class MailTemplateService {
* @param array $markers
* @return string
*/
public
static
function
registerTemplate
(
$extension
,
$templateName
,
$description
,
array
$markers
)
{
public
static
function
registerTemplate
(
$extension
,
$templateName
,
$templatePath
,
$description
,
array
$markers
)
{
MailTemplateService
::
$registerArray
[
$extension
][
$templateName
]
=
[
'templatePath'
=>
$templatePath
,
'description'
=>
$description
,
'marker'
=>
$markers
,
'extension'
=>
$extension
,
...
...
@@ -205,17 +206,24 @@ class MailTemplateService {
$this
->
extensionKey
,
$this
->
templateName
,
$this
->
language
)
->
getFirst
();
// If there is no template for this language, use the english template
if
(
$template
===
NULL
&&
$this
->
language
!==
'en'
)
{
$this
->
setLanguage
(
'en'
);
$this
->
sendEmail
();
// If there is no template for this language, use the default template
if
(
$template
===
NULL
)
{
$templatePath
=
self
::
$registerArray
[
$this
->
extensionKey
][
$this
->
templateName
][
'templatePath'
];
$templateFile
=
$templatePath
.
$this
->
language
.
'.template.html'
;
if
(
file_exists
(
$templateFile
))
{
$defaultTemplateContent
=
file_get_contents
(
$templatePath
.
$this
->
language
.
'.template.html'
);
}
else
{
// no language found and no default template
return
FALSE
;
}
}
if
(
$template
===
NULL
)
{
return
FALSE
;
if
(
!
isset
(
$defaultTemplateContent
))
{
$emailView
->
setTemplateSource
(
$template
->
getContent
());
}
else
{
$emailView
->
setTemplateSource
(
$defaultTemplateContent
);
}
$emailView
->
setTemplateSource
(
$template
->
getContent
());
$emailView
->
assignMultiple
(
$this
->
markers
);
$emailBody
=
$emailView
->
render
();
...
...
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