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

[TASK] Code cleanups

parent 30ce9360
No related branches found
No related tags found
1 merge request!2Feature multiclient
......@@ -80,7 +80,7 @@ class MailController extends ActionController {
$selectedTemplate = NULL, $selectedExtension = NULL, $selectedLanguageLeft = NULL,
$selectedLanguageRight = NULL
) {
$siteRootId = BackendService::getSiteRoot();
$siteRootId = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get(PhpSession::class);
......@@ -271,7 +271,7 @@ class MailController extends ActionController {
$selectedExtension, $selectedTemplate, $selectedLanguage, $selectedContent, $selectedSubject,
$selectedFromName, $selectedFromMail, $selectedCc, $selectedBcc, $selectedReplyTo
) {
$siteRootId = BackendService::getSiteRoot();
$siteRootId = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
/** @var Template $template */
$template = $this->templateRepository->findOneByTemplate(
......
......@@ -69,8 +69,7 @@ class QueueController extends ActionController {
$selectedTemplate = key($registerArray[$selectedExtension]);
}
$siterootPageUid = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$siteRootId = BackendService::getSiteRoot($siterootPageUid);
$siteRootId = BackendService::getSiteRoot((int) GeneralUtility::_GP('id'));
$queue = $this->mailRepository->findAllEntries($selectedExtension, $selectedTemplate, $siteRootId);
// create doc header component
......
......@@ -298,14 +298,14 @@ class Mail extends AbstractEntity {
}
/**
* @return mixed
* @return int
*/
public function getSiteRootId() {
return $this->siteRootId;
}
/**
* @param mixed $siteRootId
* @param int $siteRootId
*/
public function setSiteRootId($siteRootId) {
$this->siteRootId = (int) $siteRootId;
......
......@@ -228,14 +228,14 @@ class Template extends AbstractEntity {
}
/**
* @return mixed
* @return int
*/
public function getSiteRootId() {
return $this->siteRootId;
}
/**
* @param mixed $siteRootId
* @param int $siteRootId
*/
public function setSiteRootId($siteRootId) {
$this->siteRootId = (int) $siteRootId;
......
......@@ -38,11 +38,11 @@ class TemplateRepository extends AbstractRepository {
* @param string $extensionKey
* @param string $templateName
* @param string $language
* @param int $siteroot
* @param int $siteRoot
*
* @return Template
*/
public function findOneByTemplate($extensionKey, $templateName, $language, $siteroot = 0) {
public function findOneByTemplate($extensionKey, $templateName, $language, $siteRoot = 0) {
$query = $this->createQuery();
$querySettings = $this->objectManager->get(Typo3QuerySettings::class);
......@@ -51,14 +51,14 @@ class TemplateRepository extends AbstractRepository {
$constraintsAnd[] = $query->equals('extension_key', $extensionKey);
$constraintsAnd[] = $query->equals('template_name', $templateName);
$constraintsAnd[] = $query->equals('language', $language);
$constraintsAnd[] = $query->equals('site_root_id', (int) $siteroot);
$constraintsAnd[] = $query->equals('site_root_id', (int) $siteRoot);
$query->matching(
$query->logicalAnd($constraintsAnd)
);
/** @var Template $template */
$template = $query->execute()->getFirst();
$template = $query->setLimit(1)->execute()->getFirst();
return $template;
}
......
......@@ -102,11 +102,12 @@ class BackendService {
/**
* Retrieves the next site root in the page hierarchy from the current page
*
* @param int $currentPid
* @return int
*/
public static function getSiteRoot() {
$rootLine = BackendUtility::BEgetRootLine((int) GeneralUtility::_GP('id'));
$siteRoot = [];
public static function getSiteRoot($currentPid) {
$rootLine = BackendUtility::BEgetRootLine((int) $currentPid);
$siteRoot = ['uid' => 0];
foreach ($rootLine as $page) {
if ($page['is_siteroot'] === '1') {
......@@ -197,11 +198,12 @@ class BackendService {
$selectedTemplates = [];
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var LanguageRepository $languageRepository */
/** @var TemplateRepository $templateRepository */
$templateRepository = $objectManager->get(TemplateRepository::class);
$session->setDataByKey('selectedLanguageLeft', $selectedLanguages['left']);
$session->setDataByKey('selectedLanguageRight', $selectedLanguages['right']);
$selectedTemplates['left'] = $templateRepository->findOneByTemplate(
$selectedExtension, $selectedTemplate, $selectedLanguages['left'], $siteRootId
);
......
......@@ -140,11 +140,6 @@ class MailTemplateService {
*/
protected $objectManager;
/**
* @var array
*/
private $attachments = [];
/**
* MailTemplateService constructor.
*
......@@ -282,35 +277,6 @@ class MailTemplateService {
return self::$registerArray;
}
/**
* Sets the predefined values for this template, supplied by the Editor, if possible
* values for cc, bcc, replyTo, fromMail and fromName
*
* @param string $extensionKey
* @param string $templateName
* @param string $language
* @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, $siteRootId
);
if ($template !== NULL) {
$this->setCcAddresses(GeneralUtility::trimExplode(',', $template->getCc()));
$this->setBccAddresses(GeneralUtility::trimExplode(',', $template->getBcc()));
$this->setReplyToAddress($template->getReplyTo());
$this->setFromAddress($template->getFromMail(), $template->getFromName());
return TRUE;
}
return FALSE;
}
/**
* Send the Email
*
......
......@@ -60,11 +60,11 @@ class TypoScriptSettingsService implements SingletonInterface {
$_POST['id'] = $pageId;
/** @var TypoScriptService $typoScriptService */
$class = TypoScriptService::class;
$class = 'TYPO3\CMS\Extbase\Service\TypoScriptService';
$typoScriptService = $this->objectManager->get($class);
/** @var BackendConfigurationManager $configurationManager */
$class = BackendConfigurationManager::class;
$class = 'TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager';
$configurationManager = $this->objectManager->get($class);
self::$typoScriptCache[$extensionKey . $pageId] = $typoScriptService->convertTypoScriptArrayToPlainArray(
......
......@@ -10,10 +10,10 @@ module.tx_sgmail {
# default from address
default.from = noreply@example.org
# comma-separated list of additional bcc adresses
# comma-separated list of additional bcc addresses
default.bcc =
# comma-separated list of additional cc adresses
# comma-separated list of additional cc addresses
default.cc =
}
......
......@@ -15,7 +15,7 @@ CREATE TABLE tx_sgmail_domain_model_mail (
template_name varchar(30) DEFAULT '' NOT NULL,
reply_to varchar(30) DEFAULT '' NOT NULL,
sending_time int(11) unsigned DEFAULT '0' NOT NULL,
site_root_id int(11) DEFAULT 0 NOT NULL,
site_root_id int(11) unsigned DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
......@@ -33,7 +33,7 @@ CREATE TABLE tx_sgmail_domain_model_template (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
site_root_id int(11) DEFAULT 0 NOT NULL,
site_root_id int(11) unsigned DEFAULT '0' NOT NULL,
subject text NOT NULL,
extension_key varchar(255) DEFAULT '' NOT NULL,
template_name varchar(255) DEFAULT '' NOT NULL,
......
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