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

[TASK] Refactored usages of getRegisterArray

parent 3e9f51f8
No related branches found
No related tags found
1 merge request!11Feature security update
...@@ -410,7 +410,9 @@ class BackendService { ...@@ -410,7 +410,9 @@ class BackendService {
*/ */
public static function getNonBlacklistedTemplates($siteRootId): array { public static function getNonBlacklistedTemplates($siteRootId): array {
$siteRootId = (int) $siteRootId; $siteRootId = (int) $siteRootId;
$registerArray = MailTemplateService::getRegisterArray();
$registerService = GeneralUtility::makeInstance(RegisterService::class);
$registerArray = $registerService->getRegisterArray();
$extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sg_mail'], []); $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sg_mail'], []);
if (isset($extensionConfiguration['excludeTemplates']) && $extensionConfiguration['excludeTemplates'] !== '') { if (isset($extensionConfiguration['excludeTemplates']) && $extensionConfiguration['excludeTemplates'] !== '') {
......
...@@ -256,6 +256,8 @@ class MailTemplateService { ...@@ -256,6 +256,8 @@ class MailTemplateService {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
*/ */
public function sendEmail($isPreview = FALSE): bool { public function sendEmail($isPreview = FALSE): bool {
$registerService = GeneralUtility::makeInstance(RegisterService::class);
if (TYPO3_MODE === 'FE') { if (TYPO3_MODE === 'FE') {
/** @var TypoScriptFrontendController $tsfe */ /** @var TypoScriptFrontendController $tsfe */
$tsfe = $GLOBALS['TSFE']; $tsfe = $GLOBALS['TSFE'];
...@@ -297,8 +299,7 @@ class MailTemplateService { ...@@ -297,8 +299,7 @@ class MailTemplateService {
$defaultTemplateContent = NULL; $defaultTemplateContent = NULL;
// If there is no template for this language, use the default template // If there is no template for this language, use the default template
if ($template === NULL) { if ($template === NULL) {
$templatePath = $registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['templatePath'];
$templatePath = self::getRegisterArray()[$this->extensionKey][$this->templateName]['templatePath'];
// only standard template file is considered since version 4.1 // only standard template file is considered since version 4.1
$defaultTemplateFile = $templatePath . 'template.html'; $defaultTemplateFile = $templatePath . 'template.html';
...@@ -324,7 +325,8 @@ class MailTemplateService { ...@@ -324,7 +325,8 @@ class MailTemplateService {
if ($isPreview) { if ($isPreview) {
$previewMarker = []; $previewMarker = [];
/** @var array $markerArray */ /** @var array $markerArray */
$markerArray = self::getRegisterArray()[$this->extensionKey][$this->templateName]['marker'];
$markerArray = $registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['marker'];
foreach ($markerArray as $marker) { foreach ($markerArray as $marker) {
$markerPath = GeneralUtility::trimExplode('.', $marker['marker']); $markerPath = GeneralUtility::trimExplode('.', $marker['marker']);
$temporaryMarkerArray = []; $temporaryMarkerArray = [];
...@@ -358,10 +360,10 @@ class MailTemplateService { ...@@ -358,10 +360,10 @@ class MailTemplateService {
$emailView->setTemplateSource($template->getContent()); $emailView->setTemplateSource($template->getContent());
} else { } else {
$subject = self::getRegisterArray()[$this->extensionKey][$this->templateName]['subject']; $subject = $registerService->getRegisterArray()[$this->extensionKey][$this->templateName]['subject'];
if (\is_array($subject)) { if (\is_array($subject)) {
$subject = \trim( $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) { if ($subject === NULL && $this->subject !== NULL) {
......
...@@ -124,7 +124,7 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface { ...@@ -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 // get the location where automatic registrations should be stored
$configurationLocation = $this->getRegistrationPath(); $configurationLocation = $this->getRegistrationPath();
$registerFolder = GeneralUtility::getFileAbsFileName( $registerFolder = GeneralUtility::getFileAbsFileName(
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
use SGalinski\SgMail\Service\RegisterService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/** /**
* Class ExtensionConfiguration * Class ExtensionConfiguration
* *
...@@ -40,7 +43,8 @@ class ExtensionConfiguration { ...@@ -40,7 +43,8 @@ class ExtensionConfiguration {
$result = ''; $result = '';
try { try {
$registerArray = \SGalinski\SgMail\Service\MailTemplateService::getRegisterArray(); $registerService = GeneralUtility::makeInstance(RegisterService::class);
$registerArray = $registerService->getRegisterArray();
foreach ($registerArray as $extensionKey => $extension) { foreach ($registerArray as $extensionKey => $extension) {
/** @var array $extension */ /** @var array $extension */
foreach ($extension as $templateKey => $template) { foreach ($extension as $templateKey => $template) {
......
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