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

[TASK] Code cleanup

parent 50751613
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,7 @@ class QueueController extends ActionController {
*
* @param MailRepository $mailRepository
*/
public function injectMailRepository(MailRepository $mailRepository) {
public function injectMailRepository(MailRepository $mailRepository): void {
$this->mailRepository = $mailRepository;
}
......@@ -73,12 +73,14 @@ class QueueController extends ActionController {
/**
* @param ViewInterface $view
*/
public function initializeView(ViewInterface $view) {
public function initializeView(ViewInterface $view): void {
parent::initializeView($view);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsInlineCode('typo3_version', 'TYPO3.version='
$pageRenderer->addJsInlineCode(
'typo3_version', 'TYPO3.version='
. VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version())
. ';');
. ';'
);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pageRenderer->loadExtJS();
}
......@@ -95,7 +97,7 @@ class QueueController extends ActionController {
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
public function indexAction($selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []) {
public function indexAction($selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []): void {
$pageUid = (int) GeneralUtility::_GP('id');
if (!($this->session instanceof PhpSession)) {
......@@ -194,7 +196,7 @@ class QueueController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
public function sendMailAction($uid) {
public function sendMailAction($uid): void {
$mailService = new MailTemplateService();
if ($mailService->sendMailFromQueue($uid)) {
$message = LocalizationUtility::translate('backend.success_mail_queue', 'sg_mail');
......@@ -218,7 +220,7 @@ class QueueController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \InvalidArgumentException
*/
public function exportAction(array $filters = []) {
public function exportAction(array $filters = []): void {
$exportString = BackendService::getCsvFromQueue($filters);
header('Content-Type: application/force-download');
......
......@@ -42,7 +42,7 @@ class FormsFinisher extends AbstractFinisher {
*
* @var array
*/
const IGNORE_FIELDS = [
public const IGNORE_FIELDS = [
'Honeypot', 'Hidden'
];
......
......@@ -49,20 +49,20 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
*/
class BackendService {
// options for the queue search filter
const SENDER_FILTER_OPTION = 0;
const RECIPIENT_FILTER_OPTION = 1;
const SUBJECT_FILTER_OPTION = 2;
const MAILTEXT_FILTER_OPTION = 3;
const CC_FILTER_OPTION = 4;
const BCC_FILTER_OPTION = 5;
const FROM_NAME_FILTER_OPTION = 6;
const REPLY_TO_NAME_FILTER_OPTION = 7;
public const SENDER_FILTER_OPTION = 0;
public const RECIPIENT_FILTER_OPTION = 1;
public const SUBJECT_FILTER_OPTION = 2;
public const MAILTEXT_FILTER_OPTION = 3;
public const CC_FILTER_OPTION = 4;
public const BCC_FILTER_OPTION = 5;
public const FROM_NAME_FILTER_OPTION = 6;
public const REPLY_TO_NAME_FILTER_OPTION = 7;
// constants for deetermining the backend mode
const BACKEND_MODE_EDITOR = 'editor';
const BACKEND_MODE_EDITOR_CONTROLLER = 'Mail';
const BACKEND_MODE_QUEUE = 'queue';
const BACKEND_MODE_QUEUE_CONTROLLER = 'Queue';
public const BACKEND_MODE_EDITOR = 'editor';
public const BACKEND_MODE_EDITOR_CONTROLLER = 'Mail';
public const BACKEND_MODE_QUEUE = 'queue';
public const BACKEND_MODE_QUEUE_CONTROLLER = 'Queue';
/**
* Get all pages the be user has access to
......@@ -122,7 +122,7 @@ class BackendService {
* @throws \InvalidArgumentException
* @throws \UnexpectedValueException
*/
public static function makeButtons($docHeaderComponent, $request) {
public static function makeButtons($docHeaderComponent, $request): void {
/** @var ButtonBar $buttonBar */
$buttonBar = $docHeaderComponent->getButtonBar();
......@@ -446,7 +446,7 @@ class BackendService {
$currentSiteBlacklist = GeneralUtility::trimExplode(',', $currentSite, TRUE);
if ((int) $currentSiteBlacklist[0] === $siteRootId) {
foreach ($currentSiteBlacklist as $excludedTemplate) {
list($extensionKey, $templateName) = GeneralUtility::trimExplode('.', $excludedTemplate);
[$extensionKey, $templateName] = GeneralUtility::trimExplode('.', $excludedTemplate);
if ($extensionKey && $templateName && isset($registerArray[$extensionKey][$templateName])) {
unset($registerArray[$extensionKey][$templateName]);
}
......@@ -463,7 +463,7 @@ class BackendService {
',', $extensionConfiguration['excludeTemplatesAllDomains'], TRUE
);
foreach ($excludedTemplates as $excludedTemplate) {
list($extensionKey, $templateName) = GeneralUtility::trimExplode('.', $excludedTemplate);
[$extensionKey, $templateName] = GeneralUtility::trimExplode('.', $excludedTemplate);
if ($extensionKey && $templateName && isset($registerArray[$extensionKey][$templateName])) {
unset($registerArray[$extensionKey][$templateName]);
}
......
......@@ -36,7 +36,6 @@ use Swift_OutputByteStream;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Object\ObjectManager;
......@@ -50,16 +49,16 @@ use TYPO3\CMS\Frontend\Page\PageRepository;
* MailTemplateService
*/
class MailTemplateService {
const MARKER_TYPE_STRING = 'String';
const MARKER_TYPE_ARRAY = 'Array';
const MARKER_TYPE_OBJECT = 'Object';
const MARKER_TYPE_FILE = 'File';
const DEFAULT_LANGUAGE = 'default';
const DEFAULT_TEMPLATE_PATH = 'Resources/Private/Templates/SgMail/';
const CACHE_NAME = 'sg_mail_registerArrayCache';
const CACHE_LIFETIME_IN_SECONDS = 86400;
const REGISTER_FILE = 'Register.php';
const CONFIG_PATH = 'Configuration/MailTemplates';
public const MARKER_TYPE_STRING = 'String';
public const MARKER_TYPE_ARRAY = 'Array';
public const MARKER_TYPE_OBJECT = 'Object';
public const MARKER_TYPE_FILE = 'File';
public const DEFAULT_LANGUAGE = 'default';
public const DEFAULT_TEMPLATE_PATH = 'Resources/Private/Templates/SgMail/';
public const CACHE_NAME = 'sg_mail_registerArrayCache';
public const CACHE_LIFETIME_IN_SECONDS = 86400;
public const REGISTER_FILE = 'Register.php';
public const CONFIG_PATH = 'Configuration/MailTemplates';
/**
* @var string $toAddresses
......@@ -214,7 +213,7 @@ class MailTemplateService {
/**
* @param string $fromName
*/
public function setFromName($fromName) {
public function setFromName($fromName): void {
$this->fromName = $fromName;
}
......@@ -223,7 +222,7 @@ class MailTemplateService {
*
* @param string $markerType
*/
public static function getReadableMarkerType($markerType) {
public static function getReadableMarkerType($markerType): void {
switch ($markerType) {
case self::MARKER_TYPE_STRING :
LocalizationUtility::translate('backend.marker.type.string', 'sg_mail');
......@@ -385,6 +384,7 @@ class MailTemplateService {
*
* @param FileInterface|FileReference $file
* @return MailTemplateService
* @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
*/
public function addFileResourceAttachment($file): MailTemplateService {
if ($file instanceof FileReference) {
......@@ -455,7 +455,7 @@ class MailTemplateService {
/**
* @param string $subject
*/
public function setSubject(string $subject) {
public function setSubject(string $subject): void {
$this->subject = $subject;
}
......@@ -689,7 +689,7 @@ class MailTemplateService {
private function addMailToMailQueue(
$extensionKey, $templateName, $subject, $emailBody, $priority, $sendingTime = 0,
$lastSendingTime = 0, $language = self::DEFAULT_LANGUAGE, $pid = 0
) {
): Mail {
$mail = $this->objectManager->get(Mail::class);
$mail->setPid($pid);
$mail->setExtensionKey($extensionKey);
......@@ -730,7 +730,7 @@ class MailTemplateService {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
* @throws \Exception
*/
public function sendMailFromQueue($uid) {
public function sendMailFromQueue($uid): ?bool {
$mailRepository = $this->objectManager->get(MailRepository::class);
/** @var Mail $mailToSend */
$mailToSend = $mailRepository->findOneByUid($uid);
......@@ -792,7 +792,7 @@ class MailTemplateService {
*
* @param Template $template
*/
private function loadTemplateValues($template) {
private function loadTemplateValues($template): void {
$fromName = \trim($template->getFromName());
if ($fromName === '' && $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']) {
$fromName = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'];
......
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