From 979709f6d5dc6af88af5a6b43a5dd98f2cbb1a45 Mon Sep 17 00:00:00 2001
From: Torsten Oppermann <torsten@sgalinski.de>
Date: Tue, 18 Sep 2018 08:55:40 +0200
Subject: [PATCH] [TASK] Refactored usages of getRegisterArray

---
 Classes/Service/BackendService.php          |  4 +++-
 Classes/Service/MailTemplateService.php     | 12 +++++++-----
 Classes/Service/RegisterService.php         |  2 +-
 Classes/UserFunc/ExtensionConfiguration.php |  6 +++++-
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/Classes/Service/BackendService.php b/Classes/Service/BackendService.php
index fc7eb062..fe839507 100644
--- a/Classes/Service/BackendService.php
+++ b/Classes/Service/BackendService.php
@@ -410,7 +410,9 @@ class BackendService {
 	 */
 	public static function getNonBlacklistedTemplates($siteRootId): array {
 		$siteRootId = (int) $siteRootId;
-		$registerArray = MailTemplateService::getRegisterArray();
+
+		$registerService = GeneralUtility::makeInstance(RegisterService::class);
+		$registerArray = $registerService->getRegisterArray();
 		$extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sg_mail'], []);
 
 		if (isset($extensionConfiguration['excludeTemplates']) && $extensionConfiguration['excludeTemplates'] !== '') {
diff --git a/Classes/Service/MailTemplateService.php b/Classes/Service/MailTemplateService.php
index 5554779f..7842bd25 100644
--- a/Classes/Service/MailTemplateService.php
+++ b/Classes/Service/MailTemplateService.php
@@ -256,6 +256,8 @@ class MailTemplateService {
 	 * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
 	 */
 	public function sendEmail($isPreview = FALSE): bool {
+		$registerService = GeneralUtility::makeInstance(RegisterService::class);
+
 		if (TYPO3_MODE === 'FE') {
 			/** @var TypoScriptFrontendController $tsfe */
 			$tsfe = $GLOBALS['TSFE'];
@@ -297,8 +299,7 @@ class MailTemplateService {
 		$defaultTemplateContent = NULL;
 		// If there is no template for this language, use the default template
 		if ($template === NULL) {
-
-			$templatePath = self::getRegisterArray()[$this->extensionKey][$this->templateName]['templatePath'];
+			$templatePath = $registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['templatePath'];
 
 			// only standard template file is considered since version 4.1
 			$defaultTemplateFile = $templatePath . 'template.html';
@@ -324,7 +325,8 @@ class MailTemplateService {
 		if ($isPreview) {
 			$previewMarker = [];
 			/** @var array $markerArray */
-			$markerArray = self::getRegisterArray()[$this->extensionKey][$this->templateName]['marker'];
+
+			$markerArray = $registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['marker'];
 			foreach ($markerArray as $marker) {
 				$markerPath = GeneralUtility::trimExplode('.', $marker['marker']);
 				$temporaryMarkerArray = [];
@@ -358,10 +360,10 @@ class MailTemplateService {
 
 			$emailView->setTemplateSource($template->getContent());
 		} else {
-			$subject = self::getRegisterArray()[$this->extensionKey][$this->templateName]['subject'];
+			$subject = $registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['subject'];
 			if (\is_array($subject)) {
 				$subject = \trim(
-					self::getRegisterArray()[$this->extensionKey][$this->templateName]['subject'][$this->language]
+					$registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['subject'][$this->language]
 				);
 			}
 			if ($subject === NULL && $this->subject !== NULL) {
diff --git a/Classes/Service/RegisterService.php b/Classes/Service/RegisterService.php
index e4b8831c..e4ffc435 100644
--- a/Classes/Service/RegisterService.php
+++ b/Classes/Service/RegisterService.php
@@ -124,7 +124,7 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
 			}
 		}
 
-		// @TODO read automatically created extension registrations and write the entries
+		// read automatically created extension registrations and write the entries
 		// get the location where automatic registrations should be stored
 		$configurationLocation = $this->getRegistrationPath();
 		$registerFolder = GeneralUtility::getFileAbsFileName(
diff --git a/Classes/UserFunc/ExtensionConfiguration.php b/Classes/UserFunc/ExtensionConfiguration.php
index 3e01d938..09cde558 100644
--- a/Classes/UserFunc/ExtensionConfiguration.php
+++ b/Classes/UserFunc/ExtensionConfiguration.php
@@ -24,6 +24,9 @@
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use SGalinski\SgMail\Service\RegisterService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * Class ExtensionConfiguration
  *
@@ -40,7 +43,8 @@ class ExtensionConfiguration {
 		$result = '';
 
 		try {
-			$registerArray = \SGalinski\SgMail\Service\MailTemplateService::getRegisterArray();
+			$registerService = GeneralUtility::makeInstance(RegisterService::class);
+			$registerArray = $registerService->getRegisterArray();
 			foreach ($registerArray as $extensionKey => $extension) {
 				/** @var array $extension */
 				foreach ($extension as $templateKey => $template) {
-- 
GitLab