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

[TASK] Adding functioniality to register with an object. Providing translations for marker types

parent 660cbcad
No related branches found
No related tags found
No related merge requests found
......@@ -72,9 +72,6 @@ class QueueController extends ActionController {
* @param int $uid
*/
public function sendMailAction($uid) {
/** @var Mail $mail */
$mail = $this->mailRepository->findByUid($uid)->getFirst();
$mailService = new MailTemplateService();
$mailService->sendMailFromQueue($uid);
......
......@@ -44,30 +44,8 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
* MailTemplateService
*/
class MailTemplateService {
/**
* @var string
*/
const MARKER_TYPE_STRING = 'String';
/**
* @var string
*/
const MARKER_TYPE_DATE = 'Date';
/**
* @var string
*/
const MARKER_TYPE_INTEGER = 'Integer';
/**
* @var string
*/
const MARKER_TYPE_ARRAY = 'Array';
/**
* @var string
*/
const MARKER_TYPE_OBJECT = 'Object';
/**
......@@ -237,6 +215,26 @@ class MailTemplateService {
];
}
/**
* call in extlocalconf of an extension if you have a custom register class
*
* @param RegisterInterface
*
* @return bool
*/
public static function registerByFile($fileNameWithNamespace) {
$registerObject = GeneralUtility::makeInstance($fileNameWithNamespace);
// check instance of interface
if (!($registerObject instanceof RegisterInterface)) {
return FALSE;
}
// object ruft registerTemplate auf, beinhaltet alles aus extlocalconf
$registerObject->init();
$registerObject->registerTemplate();
return TRUE;
}
/**
* Return default markers for sg_mail
*
......@@ -387,10 +385,10 @@ class MailTemplateService {
$this->mailMessage->send();
$dateTime = new DateTime();
$this->addMailToMailQueue(
$this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority, $dateTime->getTimestamp(), TRUE
$this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority,
$dateTime->getTimestamp(), TRUE
);
} else {
$this->addMailToMailQueue($this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority);
}
......@@ -409,7 +407,9 @@ class MailTemplateService {
* @param int $priority
* @param bool $sent
*/
private function addMailToMailQueue($extensionKey, $templateName, $subject, $emailBody, $priority, $sendingTime = 0, $sent = FALSE) {
private function addMailToMailQueue(
$extensionKey, $templateName, $subject, $emailBody, $priority, $sendingTime = 0, $sent = FALSE
) {
$mail = $this->objectManager->get(Mail::class);
$mail->setExtensionKey($extensionKey);
$mail->setTemplateName($templateName);
......@@ -487,7 +487,7 @@ class MailTemplateService {
*/
public function setCcAddresses($ccAddresses) {
$this->ccAddresses = $ccAddresses;
$this->mailMessage->setCc(explode(',',$this->ccAddresses));
$this->mailMessage->setCc(explode(',', $this->ccAddresses));
return $this;
}
......@@ -607,4 +607,25 @@ class MailTemplateService {
public function setFromName($fromName) {
$this->fromName = $fromName;
}
/**
* Provides translation for the marker data type
*
* @param string $markerType
*/
public static function getReadableMarkerType($markerType) {
switch ($markerType) {
case self::MARKER_TYPE_STRING :
LocalizationUtility::translate('backend.marker.type.string', 'sg_mail');
break;
case self::MARKER_TYPE_ARRAY :
LocalizationUtility::translate('backend.marker.type.array', 'sg_mail');
break;
case self::MARKER_TYPE_OBJECT :
LocalizationUtility::translate('backend.marker.type.object', 'sg_mail');
break;
default:
LocalizationUtility::translate('backend.marker.type.mixed', 'sg_mail');
}
}
}
<?php
namespace SGalinski\SgMail\Service;
/***************************************************************
* 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!
***************************************************************/
/**
* Interface RegisterInterface
* describes behaviour of objects that want to register a template with sg_mail
*
* @package SGalinski\SgMail\Service
*/
interface RegisterInterface {
/**
* initialize certain values
*
* @return mixed
*/
public function init();
/**
* call MailTemplateService registerTemplate with according values
*
* @return mixed
*/
public function registerTemplate();
}
?>
\ No newline at end of file
......@@ -9,120 +9,129 @@
<authorEmail>torsten@sgalinski.de</authorEmail>
</header>
<body>
<trans-unit id="backend.bcc">
<source>Bcc (Comma separated if multiple):</source>
</trans-unit>
<trans-unit id="backend.button_reset">
<source>Reset Template</source>
</trans-unit>
<trans-unit id="backend.button_reset_all">
<source>Reset all</source>
</trans-unit>
<trans-unit id="backend.cc">
<source>cc (Comma separated if multiple):</source>
</trans-unit>
<trans-unit id="backend.content">
<source>Text</source>
</trans-unit>
<trans-unit id="backend.delete_template">
<source>Do you really want to reset this Template ?</source>
</trans-unit>
<trans-unit id="backend.description">
<source>Description</source>
</trans-unit>
<trans-unit id="backend.email">
<source>Email</source>
</trans-unit>
<trans-unit id="backend.failure_mail">
<source>There was an error when sending the Preview Email. Please check your Configuration</source>
</trans-unit>
<trans-unit id="backend.fromAddress">
<source>From</source>
</trans-unit>
<trans-unit id="backend.fromMail">
<source>From E-Mail Address:</source>
</trans-unit>
<trans-unit id="backend.fromName">
<source>From Name:</source>
</trans-unit>
<trans-unit id="backend.mail_queue">
<source>Mail Queue</source>
</trans-unit>
<trans-unit id="backend.marker">
<source>Marker</source>
</trans-unit>
<trans-unit id="backend.no_extension">
<source>No Extension was registered</source>
</trans-unit>
<trans-unit id="backend.not_sent">
<source>Not Sent</source>
</trans-unit>
<trans-unit id="backend.priority">
<source>Priority</source>
</trans-unit>
<trans-unit id="backend.replyTo">
<source>Reply to:</source>
</trans-unit>
<trans-unit id="backend.save">
<source>Save</source>
</trans-unit>
<trans-unit id="backend.select_language">
<source>Language (Reloads the page):</source>
</trans-unit>
<trans-unit id="backend.send_mail_again">
<source>Send this E-Mail again ?</source>
</trans-unit>
<trans-unit id="backend.send_mail_manually">
<source>Send this E-Mail now ?</source>
</trans-unit>
<trans-unit id="backend.send_test">
<source>Send Preview Mail</source>
</trans-unit>
<trans-unit id="backend.sending_time">
<source>Sending Time</source>
</trans-unit>
<trans-unit id="backend.sent">
<source>Sent</source>
</trans-unit>
<trans-unit id="backend.subject">
<source>Subject:</source>
</trans-unit>
<trans-unit id="backend.success">
<source>Successfully saved !</source>
</trans-unit>
<trans-unit id="backend.success_mail">
<source>Preview Email sent</source>
</trans-unit>
<trans-unit id="backend.template_editor">
<source>Template Editor</source>
</trans-unit>
<trans-unit id="backend.template_path">
<source>Template Path:</source>
</trans-unit>
<trans-unit id="backend.template_reset">
<source>Template was resetted succesfully</source>
</trans-unit>
<trans-unit id="backend.toAddress">
<source>To</source>
</trans-unit>
<trans-unit id="backend.type">
<source>Type</source>
</trans-unit>
<trans-unit id="backend.value">
<source>Value</source>
</trans-unit>
<trans-unit id="mlang_labels_tabdescr">
<source>Mail Templates</source>
</trans-unit>
<trans-unit id="mlang_labels_tablabel">
<source>Mail Templates</source>
</trans-unit>
<trans-unit id="mlang_tabs_tab">
<source>Mail Templates</source>
</trans-unit>
<trans-unit id="registeredExtension.action.message">
<source>Extension</source>
</trans-unit>
<trans-unit id="backend.bcc">
<source>Bcc (Comma separated if multiple):</source>
</trans-unit>
<trans-unit id="backend.button_reset">
<source>Reset Template</source>
</trans-unit>
<trans-unit id="backend.button_reset_all">
<source>Reset all</source>
</trans-unit>
<trans-unit id="backend.cc">
<source>cc (Comma separated if multiple):</source>
</trans-unit>
<trans-unit id="backend.content">
<source>Text</source>
</trans-unit>
<trans-unit id="backend.delete_template">
<source>Do you really want to reset this Template ?</source>
</trans-unit>
<trans-unit id="backend.description">
<source>Description</source>
</trans-unit>
<trans-unit id="backend.email">
<source>Email</source>
</trans-unit>
<trans-unit id="backend.failure_mail">
<source>There was an error when sending the Preview Email. Please check your Configuration</source>
</trans-unit>
<trans-unit id="backend.fromAddress">
<source>From</source>
</trans-unit>
<trans-unit id="backend.fromMail">
<source>From E-Mail Address:</source>
</trans-unit>
<trans-unit id="backend.fromName">
<source>From Name:</source>
</trans-unit>
<trans-unit id="backend.mail_queue">
<source>Mail Queue</source>
</trans-unit>
<trans-unit id="backend.marker">
<source>Marker</source>
</trans-unit>
<trans-unit id="backend.no_extension">
<source>No Extension was registered</source>
</trans-unit>
<trans-unit id="backend.not_sent">
<source>Not Sent</source>
</trans-unit>
<trans-unit id="backend.priority">
<source>Priority</source>
</trans-unit>
<trans-unit id="backend.replyTo">
<source>Reply to:</source>
</trans-unit>
<trans-unit id="backend.save">
<source>Save</source>
</trans-unit>
<trans-unit id="backend.select_language">
<source>Language (Reloads the page):</source>
</trans-unit>
<trans-unit id="backend.send_mail_again">
<source>Send this E-Mail again ?</source>
</trans-unit>
<trans-unit id="backend.send_mail_manually">
<source>Send this E-Mail now ?</source>
</trans-unit>
<trans-unit id="backend.send_test">
<source>Send Preview Mail</source>
</trans-unit>
<trans-unit id="backend.sending_time">
<source>Sending Time</source>
</trans-unit>
<trans-unit id="backend.sent">
<source>Sent</source>
</trans-unit>
<trans-unit id="backend.subject">
<source>Subject:</source>
</trans-unit>
<trans-unit id="backend.success">
<source>Successfully saved !</source>
</trans-unit>
<trans-unit id="backend.marker.type.string">
<source>String</source>
</trans-unit>
<trans-unit id="backend.marker.type.array">
<source>Array</source>
</trans-unit>
<trans-unit id="backend.marker.type.object">
<source>Object</source>
</trans-unit>
<trans-unit id="backend.success_mail">
<source>Preview Email sent</source>
</trans-unit>
<trans-unit id="backend.template_editor">
<source>Template Editor</source>
</trans-unit>
<trans-unit id="backend.template_path">
<source>Template Path:</source>
</trans-unit>
<trans-unit id="backend.template_reset">
<source>Template was resetted succesfully</source>
</trans-unit>
<trans-unit id="backend.toAddress">
<source>To</source>
</trans-unit>
<trans-unit id="backend.type">
<source>Type</source>
</trans-unit>
<trans-unit id="backend.value">
<source>Value</source>
</trans-unit>
<trans-unit id="mlang_labels_tabdescr">
<source>Mail Templates</source>
</trans-unit>
<trans-unit id="mlang_labels_tablabel">
<source>Mail Templates</source>
</trans-unit>
<trans-unit id="mlang_tabs_tab">
<source>Mail Templates</source>
</trans-unit>
<trans-unit id="registeredExtension.action.message">
<source>Extension</source>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
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