Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_mail
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_mail
Commits
cfaa2ac4
Commit
cfaa2ac4
authored
4 years ago
by
Kevin Ditscheid
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Remove unused and BS function for adding attachments
parent
bcb6661c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!30
Feature upgrade to typo3 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classes/Service/MailTemplateService.php
+13
-46
13 additions, 46 deletions
Classes/Service/MailTemplateService.php
with
13 additions
and
46 deletions
Classes/Service/MailTemplateService.php
+
13
−
46
View file @
cfaa2ac4
...
...
@@ -33,15 +33,12 @@ use SGalinski\SgMail\Domain\Model\Template;
use
SGalinski\SgMail\Domain\Repository\LayoutRepository
;
use
SGalinski\SgMail\Domain\Repository\MailRepository
;
use
SGalinski\SgMail\Domain\Repository\TemplateRepository
;
use
Swift_Attachment
;
use
Swift_OutputByteStream
;
use
TYPO3\CMS\Core\Database\ConnectionPool
;
use
TYPO3\CMS\Core\Mail\MailMessage
;
use
TYPO3\CMS\Core\Resource\File
;
use
TYPO3\CMS\Core\Resource\ResourceFactory
;
use
TYPO3\CMS\Core\Routing\SiteMatcher
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Core\Utility\VersionNumberUtility
;
use
TYPO3\CMS\Extbase\Domain\Model\FileReference
;
use
TYPO3\CMS\Extbase\Object\ObjectManager
;
use
TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
;
...
...
@@ -90,7 +87,7 @@ class MailTemplateService {
*/
protected
$objectManager
;
/**
* @var TYPO3\CMS\Core\Resource\ResourceFactory
* @var
\
TYPO3\CMS\Core\Resource\ResourceFactory
*/
protected
$resourceFactory
;
/**
...
...
@@ -364,24 +361,6 @@ class MailTemplateService {
return
$this
;
}
/**
* IMPORTANT: make sure to set $this->>ignoreMailQueue(TRUE), if you're using this method to add an attachment!
* Otherwise the attachment is ignored when sending the mail via mail queue.
*
* @param Swift_OutputByteStream $data
* @param string $filename
* @param string $contentType
* @return MailTemplateService
*/
public
function
addAttachment
(
$data
,
$filename
,
$contentType
):
MailTemplateService
{
$attachment
=
Swift_Attachment
::
newInstance
()
->
setFilename
(
$filename
)
->
setContentType
(
$contentType
)
->
setBody
(
$data
);
$this
->
mailMessage
->
attach
(
$attachment
);
return
$this
;
}
/**
* Adds a file resource as attachment
*
...
...
@@ -1046,31 +1025,19 @@ class MailTemplateService {
*/
private
function
getAvailableLanguages
():
array
{
$out
=
[
0
=>
''
];
if
(
version_compare
(
VersionNumberUtility
::
getCurrentTypo3Version
(),
'9.0.0'
,
'<'
))
{
$queryBuilder
=
GeneralUtility
::
makeInstance
(
ConnectionPool
::
class
)
->
getQueryBuilderForTable
(
'sys_language'
);
$rows
=
$queryBuilder
->
select
(
'*'
)
->
from
(
'sys_language'
)
->
execute
()
->
fetchAll
();
foreach
(
$rows
as
$row
)
{
$out
[(
int
)
$row
[
'uid'
]]
=
$row
[
'language_isocode'
];
}
}
else
{
try
{
$site
=
GeneralUtility
::
makeInstance
(
SiteMatcher
::
class
)
->
matchByPageId
(
0
);
}
catch
(
\Exception
$exception
)
{
return
[
0
=>
''
];
}
$availableLanguages
=
$site
->
getLanguages
();
$out
=
[];
foreach
(
$availableLanguages
as
$language
)
{
$languageId
=
$language
->
getLanguageId
();
if
(
$languageId
<
0
)
{
continue
;
}
$out
[
$language
->
getLanguageId
()]
=
strtolower
(
$language
->
getTwoLetterIsoCode
());
try
{
$site
=
GeneralUtility
::
makeInstance
(
SiteMatcher
::
class
)
->
matchByPageId
(
0
);
}
catch
(
\Exception
$exception
)
{
return
[
0
=>
''
];
}
$availableLanguages
=
$site
->
getLanguages
();
$out
=
[];
foreach
(
$availableLanguages
as
$language
)
{
$languageId
=
$language
->
getLanguageId
();
if
(
$languageId
<
0
)
{
continue
;
}
$out
[
$language
->
getLanguageId
()]
=
strtolower
(
$language
->
getTwoLetterIsoCode
());
}
return
$out
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment