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

[TASK] Respecting root page id when sending mails (and test) + smaller refactorings

parent 77ea4e48
No related branches found
No related tags found
1 merge request!2Feature multiclient
......@@ -80,8 +80,7 @@ class MailController extends ActionController {
$selectedTemplate = NULL, $selectedExtension = NULL, $selectedLanguageLeft = NULL,
$selectedLanguageRight = NULL
) {
$siteRoot = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$siteRootId = $siteRoot['uid'];
$siteRootId = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get('SGalinski\SgMail\Session\PhpSession');
......@@ -323,8 +322,8 @@ class MailController extends ActionController {
$selectedExtension, $selectedTemplate, $selectedLanguage, $selectedContent, $selectedSubject,
$selectedFromName, $selectedFromMail, $selectedCc, $selectedBcc, $selectedReplyTo
) {
$pageUid = (int) GeneralUtility::_GP('id');
$siteRootId = BackendService::getSiteRoot($pageUid)['uid'];
$pageUid = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$siteRootId = BackendService::getSiteRoot($pageUid);
/** @var Template $template */
$template = $this->templateRepository->findOneByTemplate(
......
......@@ -70,9 +70,8 @@ class QueueController extends ActionController {
$selectedTemplate = key($registerArray[$selectedExtension]);
}
$pageUid = (int) GeneralUtility::_GP('id');
$siteRootId = BackendService::getSiteRoot($pageUid)['uid'];
debug($siteRootId);
$pageUid = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$siteRootId = BackendService::getSiteRoot($pageUid);
$queue = $this->mailRepository->findAllEntries($selectedExtension, $selectedTemplate, $siteRootId);
// create doc header component
......
......@@ -99,7 +99,7 @@ class BackendService {
* Retrieves the next site root in the page hierarchy from the current page
*
* @param $currentPid
* @return array
* @return int
*/
public static function getSiteRoot($currentPid) {
$rootLine = BackendUtility::BEgetRootLine((int) GeneralUtility::_GP('id'));
......@@ -111,6 +111,6 @@ class BackendService {
}
}
return $siteRoot;
return $siteRoot['uid'];
}
}
......@@ -292,9 +292,12 @@ class MailTemplateService {
* @return bool
*/
public function loadPredefinedValuesForTemplate($extensionKey, $templateName, $language) {
$pageUid = (int) GeneralUtility::_GP('id');
$siteRootId = BackendService::getSiteRoot($pageUid);
/** @var Template $template */
$template = $this->templateRepository->findOneByTemplate(
$this->extensionKey, $this->templateName, $this->language
$this->extensionKey, $this->templateName, $this->language, $siteRootId
);
if ($template !== NULL) {
......@@ -316,9 +319,12 @@ class MailTemplateService {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
*/
public function sendEmail($isPreview = FALSE) {
$pageUid = (int) GeneralUtility::_GP('id');
$siteRootId = BackendService::getSiteRoot($pageUid);
/** @var Template $template */
$template = $this->templateRepository->findOneByTemplate(
$this->extensionKey, $this->templateName, $this->language
$this->extensionKey, $this->templateName, $this->language, $siteRootId
);
// if there is a template, prefer those values
......@@ -365,7 +371,7 @@ class MailTemplateService {
/** @var StandaloneView $emailView */
$emailView = $this->objectManager->get(StandaloneView::class);
if (null === $defaultTemplateContent) {
if (NULL === $defaultTemplateContent) {
$emailView->setTemplateSource($template->getContent());
$subject = $template->getSubject();
} else {
......@@ -437,7 +443,7 @@ class MailTemplateService {
$mail->setReplyTo($this->replyToAddress);
$pageUid = (int) GeneralUtility::_GP('id');
$siteRootId = BackendService::getSiteRoot($pageUid)['uid'];
$siteRootId = BackendService::getSiteRoot($pageUid);
$mail->setSiteRootId($siteRootId);
$mailRepository = $this->objectManager->get(MailRepository::class);
......
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