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
c6f468bd
Commit
c6f468bd
authored
Jun 12, 2019
by
Paul Ilea
Browse files
[BUGFIX] File references are moved from original record to mail
parent
a7e8c34d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Classes/Service/MailTemplateService.php
View file @
c6f468bd
...
...
@@ -35,6 +35,7 @@ use Swift_Attachment;
use
Swift_OutputByteStream
;
use
TYPO3\CMS\Core\Database\ConnectionPool
;
use
TYPO3\CMS\Core\Mail\MailMessage
;
use
TYPO3\CMS\Core\Resource\ResourceFactory
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Extbase\Domain\Model\FileReference
;
use
TYPO3\CMS\Extbase\Object\ObjectManager
;
...
...
@@ -153,6 +154,11 @@ class MailTemplateService {
*/
protected
$objectManager
;
/**
* @var TYPO3\CMS\Core\Resource\ResourceFactory
*/
protected
$resourceFactory
;
/**
* MailTemplateService constructor.
*
...
...
@@ -175,6 +181,7 @@ class MailTemplateService {
$tsSettings
=
$typoScriptSettingsService
->
getSettings
(
0
,
'tx_sgmail'
);
$this
->
templateRepository
=
$this
->
objectManager
->
get
(
TemplateRepository
::
class
);
$this
->
persistenceManager
=
$this
->
objectManager
->
get
(
PersistenceManager
::
class
);
$this
->
resourceFactory
=
$this
->
objectManager
->
get
(
ResourceFactory
::
class
);
// use defaultMailFromAddress if it is provided in LocalConfiguration.php; use the sg_mail TS setting as fallback
if
(
filter_var
(
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'MAIL'
][
'defaultMailFromAddress'
],
FILTER_VALIDATE_EMAIL
))
{
...
...
@@ -401,9 +408,30 @@ class MailTemplateService {
* @param FileReference $file
*
* @return MailTemplateService
* @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
*/
public
function
addFileResourceAttachment
(
FileReference
$file
):
MailTemplateService
{
$this
->
markers
[]
=
$file
;
$originalResource
=
$file
->
getOriginalResource
();
if
(
!
$originalResource
)
{
return
$this
;
}
$originalFile
=
$originalResource
->
getOriginalFile
();
if
(
!
$originalFile
)
{
return
$this
;
}
$coreFileReferenceMailFile
=
$this
->
resourceFactory
->
createFileReferenceObject
(
[
'uid_local'
=>
$originalFile
->
getUid
(),
'table_local'
=>
'sys_file'
,
'uid'
=>
uniqid
(
'NEW_MAIL'
,
TRUE
)
]
);
$newFileReference
=
GeneralUtility
::
makeInstance
(
FileReference
::
class
);
$newFileReference
->
setOriginalResource
(
$coreFileReferenceMailFile
);
$this
->
markers
[]
=
$newFileReference
;
return
$this
;
}
...
...
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