From 1bf96ddd6a3ec61a3d01fdebae58c6b68ac7a4d4 Mon Sep 17 00:00:00 2001
From: Torsten Oppermann <torsten@sgalinski.de>
Date: Thu, 4 Jan 2018 15:16:01 +0100
Subject: [PATCH] [TASK] Adding a function to determine if a single template is
 blacklisted for the siteroot

---
 Classes/Service/MailTemplateService.php | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/Classes/Service/MailTemplateService.php b/Classes/Service/MailTemplateService.php
index 392e924b..d2956c16 100644
--- a/Classes/Service/MailTemplateService.php
+++ b/Classes/Service/MailTemplateService.php
@@ -451,7 +451,7 @@ class MailTemplateService {
 	 * @return MailTemplateService
 	 */
 	public function setToAddresses($toAddresses) {
-		$toAddresses = preg_replace('~\x{00a0}~siu',' ', $toAddresses);
+		$toAddresses = preg_replace('~\x{00a0}~siu', ' ', $toAddresses);
 		$this->toAddresses = trim($toAddresses);
 		$this->mailMessage->setTo(trim($toAddresses));
 		return $this;
@@ -687,7 +687,7 @@ class MailTemplateService {
 	 * @throws \BadFunctionCallException
 	 * @return array
 	 */
-	public static function registerExtensions() {
+	public static function registerExtensions(): array {
 		// clear registerArray
 		$registerArray = [];
 
@@ -735,4 +735,25 @@ class MailTemplateService {
 
 		return $registerArray;
 	}
+
+	/**
+	 * Checks if a template is blacklisted for a given siterootId
+	 *
+	 * @param string $extensionKey
+	 * @param string $templateName
+	 * @param int $siteRootId
+	 * @return boolean
+	 * @throws \InvalidArgumentException
+	 * @throws \BadFunctionCallException
+	 * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
+	 */
+	public static function isTemplateBlacklisted($extensionKey, $templateName, $siteRootId): bool {
+		$whitelistedTemplates = BackendService::getWhitelistedTemplates($siteRootId);
+
+		if ($whitelistedTemplates[$extensionKey]) {
+			return $whitelistedTemplates[$extensionKey][$templateName] ? FALSE : TRUE;
+		}
+
+		return TRUE;
+	}
 }
-- 
GitLab