diff --git a/Classes/Service/MailTemplateService.php b/Classes/Service/MailTemplateService.php index 3b4cc4d7112a6d56afb014af5e464d5455a5efb6..654a3e740f1dec6e7bb30b597e4a74a6ef07dbe5 100644 --- a/Classes/Service/MailTemplateService.php +++ b/Classes/Service/MailTemplateService.php @@ -66,7 +66,7 @@ class MailTemplateService { /** * @var array $ccAddresses */ - private $ccAddresses = []; + private $ccAddresses; /** * @var string $replyToAddress @@ -108,12 +108,12 @@ class MailTemplateService { * * @var array $tsSettings */ - private $tsSettings = []; + private $tsSettings; /** * @var array $bccAddresses */ - private $bccAddresses = []; + private $bccAddresses; /** * @var int @@ -147,6 +147,8 @@ class MailTemplateService { /** * MailTemplateService constructor. + * + * @throws \InvalidArgumentException */ public function __construct() { /** @var ObjectManager objectManager */ @@ -221,10 +223,11 @@ class MailTemplateService { /** * call in extlocalconf of an extension if you have a custom register class * - * @param RegisterInterface - * @param boolean Should the object initialize itself ? + * @param RegisterInterface $fileNameWithNamespace + * @param boolean $initObject Should the object initialize itself ? * * @return bool + * @throws \InvalidArgumentException */ public static function registerByFile($fileNameWithNamespace, $initObject = TRUE) { $registerObject = GeneralUtility::makeInstance($fileNameWithNamespace); @@ -331,7 +334,7 @@ class MailTemplateService { $defaultTemplateContent = file_get_contents($templatePath . $this->language . '.template.html'); } else { // no language found and no default template - $this->setLanguage('en'); + $this->setLanguage($this->tsSettings['templateDefaultLanguage'] ?: 'en'); // does an english default template exist ? if (file_exists($templatePath . $this->language . '.template.html')) { $this->sendEmail(); @@ -344,6 +347,7 @@ class MailTemplateService { if ($isPreview) { $previewMarker = []; + /** @var array $markerArray */ $markerArray = self::$registerArray[$this->extensionKey][$this->templateName]['marker']; foreach ($markerArray as $marker) { if ($marker['backend_translation_key']) { @@ -361,7 +365,7 @@ class MailTemplateService { /** @var StandaloneView $emailView */ $emailView = $this->objectManager->get(StandaloneView::class); - if (!isset($defaultTemplateContent)) { + if (null === $defaultTemplateContent) { $emailView->setTemplateSource($template->getContent()); $subject = $template->getSubject(); } else { @@ -412,6 +416,7 @@ class MailTemplateService { * @param int $sendingTime * @param int $priority * @param bool $sent + * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException */ private function addMailToMailQueue( $extensionKey, $templateName, $subject, $emailBody, $priority, $sendingTime = 0, $sent = FALSE @@ -440,6 +445,8 @@ class MailTemplateService { * Send a Mail from the queue, identified by its id * * @param int $uid + * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException + * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException */ public function sendMailFromQueue($uid) { $mailRepository = $this->objectManager->get(MailRepository::class); @@ -601,7 +608,7 @@ class MailTemplateService { /** * @param Swift_OutputByteStream $data - * @param string $path + * @param string $filename * @param string $contentType * @return MailTemplateService */