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
466714d8
Commit
466714d8
authored
8 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Creating hook into formhandler in its own class
parent
c41bef54
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Service/FormhandlerFinisherService.php
+85
-0
85 additions, 0 deletions
Classes/Service/FormhandlerFinisherService.php
Classes/Service/MailTemplateService.php
+1
-47
1 addition, 47 deletions
Classes/Service/MailTemplateService.php
with
86 additions
and
47 deletions
Classes/Service/FormhandlerFinisherService.php
0 → 100644
+
85
−
0
View file @
466714d8
<?php
namespace
SGalinski\SgMail\Service
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Lang\LanguageService
;
use
Typoheads\Formhandler\Finisher\AbstractFinisher
;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Class FormhandlerFinisherService
*
* @package SGalinski\SgMail\Service
*/
class
FormhandlerFinisherService
extends
AbstractFinisher
{
/**
* Hook into Formhandler, sets config and form input
* gets called in the finisher of the typoscript
* redirects to process() function
*
* @param array $formInput
* @param array $tsConfig
*/
public
function
init
(
$formInput
,
$settings
)
{
$this
->
gp
=
$formInput
;
foreach
(
$formInput
as
&
$userInput
)
{
GeneralUtility
::
removeXSS
(
$userInput
);
}
$this
->
settings
=
$settings
;
}
/**
* Redirect Formhandler input to send Email Function
* Needed to hook into Formhandler
*/
public
function
process
()
{
/** @var $translator LanguageService */
$translator
=
(
TYPO3_MODE
===
'FE'
?
$GLOBALS
[
'TSFE'
]
:
$GLOBALS
[
'LANG'
]);
$subject
=
$translator
->
sL
(
$this
->
settings
[
'subject'
],
TRUE
);
$toAddress
=
$this
->
settings
[
'to_address'
];
if
(
$toAddress
===
'email'
)
{
$toAddress
=
$this
->
gp
[
'email'
];
}
MailTemplateService
::
sendEmail
(
'en'
,
$this
->
settings
[
'template_key'
],
$this
->
settings
[
'extension_key'
],
$toAddress
,
$this
->
settings
[
'from_address'
],
$subject
,
$this
->
gp
,
$this
->
settings
[
'ignore_mail_queue'
]
);
return
$this
->
gp
;
}
/**
* Needed to hook into Formhandler
* simply returns true
*/
public
function
validateConfig
()
{
parent
::
validateConfig
();
}
}
This diff is collapsed.
Click to expand it.
Classes/Service/MailTemplateService.php
+
1
−
47
View file @
466714d8
...
@@ -38,59 +38,13 @@ use Typoheads\Formhandler\Finisher\AbstractFinisher;
...
@@ -38,59 +38,13 @@ use Typoheads\Formhandler\Finisher\AbstractFinisher;
/**
/**
* MailTemplateService
* MailTemplateService
*/
*/
class
MailTemplateService
extends
AbstractFinisher
{
class
MailTemplateService
{
/**
/**
* @var array
* @var array
*/
*/
private
static
$registerArray
=
[];
private
static
$registerArray
=
[];
/**
* Hook into Formhandler, sets config and form input
* gets called in the finisher of the typoscript
* redirects to process() function
*
* @param $formInput
* @param $tsConfig
*/
public
function
init
(
$formInput
,
$tsConfig
)
{
$this
->
gp
=
$formInput
;
foreach
(
$formInput
as
&
$userInput
)
{
GeneralUtility
::
removeXSS
(
$userInput
);
}
$this
->
tsConfig
=
$tsConfig
;
}
/**
* Redirect Formhandler input to send Email Function
* Needed to hook into Formhandler
*/
public
function
process
()
{
/** @var $translator LanguageService */
$translator
=
(
TYPO3_MODE
===
'FE'
?
$GLOBALS
[
'TSFE'
]
:
$GLOBALS
[
'LANG'
]);
$subject
=
$translator
->
sL
(
$this
->
tsConfig
[
'subject'
],
TRUE
);
$toAddress
=
$this
->
tsConfig
[
'to_address'
];
if
(
$toAddress
===
'email'
)
{
$toAddress
=
$this
->
gp
[
'email'
];
}
self
::
sendEmail
(
'en'
,
$this
->
tsConfig
[
'template_key'
],
$this
->
tsConfig
[
'extension_key'
],
$toAddress
,
$this
->
tsConfig
[
'from_address'
],
$subject
,
$this
->
gp
,
$this
->
tsConfig
[
'ignore_mail_queue'
]
);
return
$this
->
gp
;
}
/**
* Needed to hook into Formhandler
* simply returns true
*/
public
function
validateConfig
()
{
parent
::
validateConfig
();
}
/**
/**
* register a template with sg_mail
* register a template with sg_mail
*
*
...
...
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