Skip to content
Snippets Groups Projects
Commit ab976227 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Review documentation

parent dd753a07
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,9 @@
License: [GNU GPL, Version 2](https://www.gnu.org/licenses/gpl-2.0.html)
Repository: https://gitlab.sgalinski.de/typo3/sg_routes
Repository: https://gitlab.sgalinski.de/typo3/sg_mail
Please report bugs here: https://gitlab.sgalinski.de/typo3/sg_routes
Please report bugs here: https://gitlab.sgalinski.de/typo3/sg_mail
TYPO3 version: >7.6
......@@ -37,7 +37,7 @@ A fully working example class can be found here: **SGalinski\SgMail\Example\Regi
All you need to do to get the example to work is registering your class in **ext_localconf.php** with:
\SGalinski\SgMail\Service\MailTemplateService::registerByFile('SGalinski\SgMail\Example\Register');```
\SGalinski\SgMail\Service\MailTemplateService::registerByFile('SGalinski\SgMail\Example\Register');
### Send an email with the MailTemplateService
......@@ -47,6 +47,29 @@ Basic Usage:
2. Set all desired fields (i.e. setLanguage, setToAddresses, setTemplateName, setExtensionKey etc.)
3. Invoke the **sendEmail()** function
Example:
// get an instance of the service
/** @var MailTemplateService $mailService */
$mailService = $this->objectManager->get(MailTemplateService::class);
// set the extension key & template name (mandatory!)
$mailService->setExtensionKey('your_extension_key');
$mailService->setTemplateName($this->settings['templateName']);
// set all the custom fields, these fields all have fallbacks from your configuration or the code
$mailService->setFromName($this->settings['fromName']);
$mailService->setFromAddress($this->settings['fromEmail']);
$mailService->setToAddresses([$emailAddress]);
$mailService->setIgnoreMailQueue(TRUE);
$mailService->setMarkers(['link' => $uri]);
// set the proper language for the mail
$mailService->setLanguage($GLOBALS['TSFE']->config['config']['language']);
// finally send the mail
$mailService->sendEmail();
### The mail queue
The mail queue holds all the mails that have been sent or should be sent in the future. You can view the mail queue in the backend module and interact with the entries.
......@@ -73,13 +96,12 @@ For more information on the TYPO3 scheduler extension read its [manual](https://
## Using sg_mail with Formhandler
In your **setup.ts** of your formhandler extension, you have to invoke the **FormhandlerFinisherService** of sg_mail.
In your **setup.txt** of your formhandler extension, you have to invoke the **FormhandlerFinisherService** of sg_mail.
This is done in a similar fashion as with the usual finisher classes.
### Example
```
finishers {
finishers {
1 {
class = SGalinski\SgMail\Service\FormhandlerFinisherService
config {
......@@ -92,8 +114,7 @@ finishers {
ignore_mail_queue = TRUE
}
}
}
```
}
## The Backend Module
With this extension comes a new module in the "WEB" section of your TYPO3 Backend.
......@@ -128,6 +149,20 @@ With the **Mail Queue** mode, you can see the current content of your mailing qu
## Developer Guide
### Database and Models
This extension uses two database tables:
- tx_sgmail_domain_model_template
Stores all template settings that have been provided via the backend module. The Default settings exist only in the register array and not in the database.
- tx_sgmail_domain_model_mail
This table holds all the mails in the mailing queue. When they are sent, the flag **sent** is set to true and the **sending_time** is inserted. You can inspect the mailing queue with the backend module.
If an email should ignore the mail queue, it is still inserted in this table with the **sent** flag set to true.
The extbase model classes for these tables are located at the *Domain\Model* folder.
### Service Classes
##### Register Interface
To register your extension you need at least one implementation of this interface.
......@@ -145,23 +180,23 @@ A brief description about the template, visible in the backend module
###### subject
The default subject text for the emails. It is possible to specify language specific texts with an associative array:
[
'en' => 'english subject',
'de' => 'german subject',
...
]
[
'en' => 'english subject',
'de' => 'german subject',
...
]
###### markers
This is an array of information for substitute variables that are used to replace certain values at runtime.
Each Array element should be its own array and structured like this:
[
'marker' => 'marker_name',
'type' => \SGalinski\SgMail\Service\MailTemplateService::MARKER_TYPE_STRING,
'value' => 'some value',
'description' => 'This marker is used for X in the email'
]
[
'marker' => 'marker_name',
'type' => \SGalinski\SgMail\Service\MailTemplateService::MARKER_TYPE_STRING,
'value' => 'some value',
'description' => 'This marker is used for X in the email'
]
marker = the variable name you use in the template
type = the date type of the variable
......@@ -178,6 +213,8 @@ Now you can register the class in your **ext_localconf.php** with
You find a complete example of this process in the file **SGalinski\SgMail\Example\Register**
---
#### MailTemplateService
This class provides you with an API to the mailing functionality and various helper functions regarding the your templates.
......@@ -231,27 +268,17 @@ Sets the various variables to the supplied values. With these functions you can
You can also tell the **MailTemplateService** to not ignore this mail when adding to the mailing queue: **function setIgnoreMailQueue**.
---
#### FormhandlerFinisherService
This class is an implementation of the **Typoheads\Formhandler\Finisher\AbstractFinisher** Class
that is used by the extension [formhandler extension](https://typo3.org/extensions/repository/view/formhandler).
---
#### TypoScriptSettingsService
This Service enables you to access your typoscript settings outside of your controller classes. You simply need to supply your page id and the extension key.
If you have no page id specific settings, set the page id to 0.
## Database and Models
This extension uses two database tables:
- tx_sgmail_domain_model_template
Stores all template settings that have been provided via the backend module. The Default settings exist only in the register array and not in the database.
- tx_sgmail_domain_model_mail
This table holds all the mails in the mailing queue. When they are sent, the flag **sent** is set to true and the **sending_time** is inserted. You can inspect the mailing queue with the backend module.
If an email should ignore the mail queue, it is still inserted in this table with the **sent** flag set to true.
The extbase model classes for these tables are located at the *Domain\Model* folder.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment