Commit 6eb533a4 authored by Stefan Galinski's avatar Stefan Galinski 🎮
Browse files

Merge branch 'feature_Upgrade-to-TYPO3-10' into 'master'

Feature upgrade to typo3 10

See merge request !30
parents 62c9926a e99e8afd
......@@ -29,54 +29,49 @@ namespace SGalinski\SgMail\Command;
use SGalinski\SgMail\Domain\Model\Mail;
use SGalinski\SgMail\Domain\Repository\MailRepository;
use SGalinski\SgMail\Service\PlaintextService;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use Symfony\Component\Console\Command\Command;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
/**
* Command controller for the mailing feature
*/
class SendMailCommandController extends CommandController {
class SendMailCommandController extends Command {
/**
* @var MailRepository
* Configure command
*/
protected $mailRepository;
/**
* Inject the MailRepository
*
* @param MailRepository $mailRepository
*/
public function injectMailRepository(MailRepository $mailRepository) {
$this->mailRepository = $mailRepository;
public function configure() {
$this->setDescription('Executes the sending of mails with a maximum of the given sentCount.')
->addArgument('sendCount', InputArgument::OPTIONAL, 'Send count', 50);
}
/**
* @var PersistenceManager
*/
protected $persistenceManager;
/**
* Inject the PersistenceManager
* Execute the command
*
* @param PersistenceManager $persistenceManager
*/
public function injectPersistenceManager(PersistenceManager $persistenceManager) {
$this->persistenceManager = $persistenceManager;
}
/**
* Executes the sending of mails with a maximum of the given sentCount.
*
* @param int $sendCount
* @return void
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
* @param InputInterface $input
* @param OutputInterface $output
* @return int
* @throws \TYPO3\CMS\Extbase\Object\Exception
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
*/
public function runSendMailsCommand($sendCount = 50) {
$mailsToSend = $this->mailRepository->findMailsToSend($sendCount);
public function execute(InputInterface $input, OutputInterface $output) {
$sendCount = $input->getArgument('sendCount');
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var MailRepository $mailRepository */
$mailRepository = $objectManager->get(MailRepository::class);
} else {
$mailRepository = GeneralUtility::makeInstance(MailRepository::class);
}
$mailsToSend = $mailRepository->findMailsToSend($sendCount);
foreach ($mailsToSend as $mailToSend) {
/** @var Mail $mailToSend */
$fromAddress = $mailToSend->getFromAddress();
......@@ -96,9 +91,9 @@ class SendMailCommandController extends CommandController {
if (empty($fromAddress) || empty($toAddresses)) {
continue;
}
$this->mailRepository->update($mailToSend);
$mailRepository->update($mailToSend);
$mailMessage = $this->objectManager->get(MailMessage::class);
$mailMessage = GeneralUtility::makeInstance(MailMessage::class);
$mailMessage->setFrom($fromAddress, $mailToSend->getFromName());
$mailMessage->setTo($toAddresses);
$mailMessage->setSubject($mailSubject);
......@@ -115,15 +110,21 @@ class SendMailCommandController extends CommandController {
$mailMessage->setReplyTo($replyTo);
}
$mailMessage->setBody($mailBody, 'text/html');
$plaintextService = GeneralUtility::makeInstance(PlaintextService::class);
$plaintextBody = $plaintextService->makePlain($mailBody);
$mailMessage->addPart($plaintextBody, 'text/plain');
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
$mailMessage->setBody($mailBody, 'text/html');
$mailMessage->addPart($plaintextBody, 'text/plain');
} else {
$mailMessage->html($mailBody);
$mailMessage->text($plaintextBody);
}
$attachments = $mailToSend->getAttachments();
if ($attachments->count() > 0) {
foreach ($attachments as $attachment) {
try {
/** @var FileInterface $file */
$file = $attachment->getOriginalResource();
if (!$file) {
continue;
......@@ -133,17 +134,21 @@ class SendMailCommandController extends CommandController {
if (!$file) {
continue;
}
$mailMessage->attach(
\Swift_Attachment::newInstance(
$file->getContents(), $file->getName(), $file->getMimeType()
)
);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
$mailMessage->attach(
\Swift_Attachment::newInstance(
$file->getContents(), $file->getName(), $file->getMimeType()
)
);
} else {
$mailMessage->attach($file->getContents(), $file->getName(), $file->getMimeType());
}
} catch (\Exception $exception) {
continue;
}
}
}
try {
$mailMessage->send();
} catch (\Exception $exception) {
......@@ -152,6 +157,7 @@ class SendMailCommandController extends CommandController {
}
// Important for command controllers that change data
$this->persistenceManager->persistAll();
$mailRepository->persist();
return 0;
}
}
......@@ -129,7 +129,6 @@ class ConfigurationController extends ActionController {
'docHeader' => $this->docHeaderComponent->docHeaderContent(),
'selectedTemplateFilter' => $filters['filterTemplate'],
'selectedExtensionFilter' => $filters['filterExtension'],
'typo3Version' => VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version),
'selectedTemplateKey' => $selectedTemplate,
'selectedExtensionKey' => $selectedExtension,
'mode' => 'editor'
......@@ -181,24 +180,33 @@ class ConfigurationController extends ActionController {
'markerLabel' => $markerLabel
];
}
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var RegisterService $registerService */
$registerService = $this->objectManager->get(RegisterService::class);
} else {
$registerService = GeneralUtility::makeInstance(RegisterService::class);
}
$registerService = $this->objectManager->get(RegisterService::class);
$registerService->writeRegisterFile(
$templateName, $extensionKey, $markers, $subject, $description
);
$registerService->clearCaches();
// store selected template & extension key in the session
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get(PhpSession::class);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var PhpSession session */
$this->session = $this->objectManager->get(PhpSession::class);
} else {
$this->session = GeneralUtility::makeInstance(PhpSession::class);
}
$this->session->setSessionKey('sg_mail_controller_session');
} else {
$this->session->setSessionKey('sg_mail_controller_session');
}
$this->session->setDataByKey('selectedTemplate', $templateName);
$this->session->setDataByKey('selectedExtension', self::DEFAULT_EXTENSION_KEY);
$this->redirect(
'index', 'Mail', NULL,
['message' => LocalizationUtility::translate('backend.create_message', 'sg_mail')]
......@@ -251,7 +259,13 @@ class ConfigurationController extends ActionController {
];
}
$registerService = $this->objectManager->get(RegisterService::class);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var RegisterService $registerService */
$registerService = $this->objectManager->get(RegisterService::class);
} else {
$registerService = GeneralUtility::makeInstance(RegisterService::class);
}
$registerService->migrateTemplateEntries($oldTemplateName, $oldExtensionKey, $templateName, $extensionKey);
$registerService->deleteRegisterFile($oldTemplateName);
$registerService->writeRegisterFile(
......@@ -262,7 +276,13 @@ class ConfigurationController extends ActionController {
// store selected template & extension key in the session
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get(PhpSession::class);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var PhpSession session */
$this->session = $this->objectManager->get(PhpSession::class);
} else {
$this->session = GeneralUtility::makeInstance(PhpSession::class);
}
$this->session->setSessionKey('sg_mail_controller_session');
} else {
$this->session->setSessionKey('sg_mail_controller_session');
......@@ -286,7 +306,13 @@ class ConfigurationController extends ActionController {
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public function deleteAction(string $selectedTemplate, string $selectedExtension) {
$registerService = $this->objectManager->get(RegisterService::class);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var RegisterService $registerService */
$registerService = $this->objectManager->get(RegisterService::class);
} else {
$registerService = GeneralUtility::makeInstance(RegisterService::class);
}
$registerService->deleteTemplate($selectedExtension, $selectedTemplate);
$this->redirect(
'index', 'Mail', NULL,
......
......@@ -32,7 +32,6 @@ use SGalinski\SgMail\Session\PhpSession;
use TYPO3\CMS\Backend\Clipboard\Clipboard;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
......@@ -104,15 +103,6 @@ class LayoutController extends ActionController {
*/
public function initializeView(ViewInterface $view) {
parent::initializeView($view);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsInlineCode(
'typo3_version', 'TYPO3.version='
. VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version())
. ';'
);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pageRenderer->loadExtJS();
}
$this->initClipboard();
$view->assign('controller', 'Layout');
}
......@@ -124,7 +114,13 @@ class LayoutController extends ActionController {
$pageUid = (int) GeneralUtility::_GP('id');
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get(PhpSession::class);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var PhpSession session */
$this->session = $this->objectManager->get(PhpSession::class);
} else {
$this->session = GeneralUtility::makeInstance(PhpSession::class);
}
$this->session->setSessionKey('sg_mail_controller_session');
} else {
$this->session->setSessionKey('sg_mail_controller_session');
......@@ -158,7 +154,6 @@ class LayoutController extends ActionController {
BackendService::makeButtons($this->docHeaderComponent, $this->request);
$this->view->assign('pageUid', $pageUid);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
}
/**
......
......@@ -36,7 +36,6 @@ use SGalinski\SgMail\Session\PhpSession;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
......@@ -93,15 +92,6 @@ class MailController extends ActionController {
*/
public function initializeView(ViewInterface $view) {
parent::initializeView($view);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsInlineCode(
'typo3_version', 'TYPO3.version='
. VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version())
. ';'
);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pageRenderer->loadExtJS();
}
$view->assign('controller', 'Mail');
}
......@@ -125,7 +115,13 @@ class MailController extends ActionController {
$pid = (int) GeneralUtility::_GP('id');
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get(PhpSession::class);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var PhpSession session */
$this->session = $this->objectManager->get(PhpSession::class);
} else {
$this->session = GeneralUtility::makeInstance(PhpSession::class);
}
$this->session->setSessionKey('sg_mail_controller_session');
} else {
$this->session->setSessionKey('sg_mail_controller_session');
......@@ -231,8 +227,13 @@ class MailController extends ActionController {
$this->view->assign('languageTemplates', $templates);
$this->view->assign('languageLabels', BackendService::getLanguageLabels($languages));
$this->view->assign('templates', $registerArray);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var RegisterService $registerService */
$registerService = $this->objectManager->get(RegisterService::class);
} else {
$registerService = GeneralUtility::makeInstance(RegisterService::class);
}
$registerService = $this->objectManager->get(RegisterService::class);
$this->view->assign(
'isManual', $registerService->isManuallyRegisteredTemplate($parameters['selectedTemplate'])
);
......@@ -283,21 +284,14 @@ class MailController extends ActionController {
BackendService::makeButtons($this->docHeaderComponent, $this->request);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
/** @noinspection PhpInternalEntityUsedInspection */
$this->view->assign('beUserMail', $GLOBALS['BE_USER']->user['email']);
// get the default language label and pass it to the view
$pageTsConfig = BackendUtility::getPagesTSconfig($pageUid);
if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) {
$defaultLanguageLabel = LocalizationUtility::translate(
'LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage'
);
} else {
$defaultLanguageLabel = LocalizationUtility::translate(
'lll:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'
);
}
$defaultLanguageLabel = LocalizationUtility::translate(
'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage'
);
if (isset($pageTsConfig['mod.']['SHARED.']['defaultLanguageLabel'])) {
$defaultLanguageLabel = $pageTsConfig['mod.']['SHARED.']['defaultLanguageLabel'];
......@@ -373,13 +367,19 @@ class MailController extends ActionController {
$this->redirect('index', NULL, NULL, $arguments);
}
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var \SGalinski\SgMail\Service\MailTemplateService $mailTemplateService */
$mailTemplateService = $objectManager->get(
MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension']
);
$mailIsSend = FALSE;
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var \SGalinski\SgMail\Service\MailTemplateService $mailTemplateService */
$mailTemplateService = $objectManager->get(
MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension']
);
} else {
$mailTemplateService = GeneralUtility::makeInstance(
MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension']
);
}
$mailIsSend = FALSE;
foreach ((array) $parameters['templates'] as $key => $template) {
$mailTemplateService->setLanguage($key);
$mailTemplateService->setToAddresses($parameters['emailAddress']);
......
......@@ -37,7 +37,6 @@ use SGalinski\SgMail\Session\PhpSession;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
......@@ -108,15 +107,6 @@ class NewsletterController extends ActionController {
*/
public function initializeView(ViewInterface $view) {
parent::initializeView($view);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsInlineCode(
'typo3_version', 'TYPO3.version='
. VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version())
. ';'
);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pageRenderer->loadExtJS();
}
$view->assign('controller', 'Newsletter');
}
......@@ -140,7 +130,13 @@ class NewsletterController extends ActionController {
$pid = (int) GeneralUtility::_GP('id');
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get(PhpSession::class);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var PhpSession session */
$this->session = $this->objectManager->get(PhpSession::class);
} else {
$this->session = GeneralUtility::makeInstance(PhpSession::class);
}
$this->session->setSessionKey('sg_mail_controller_session');
} else {
$this->session->setSessionKey('sg_mail_controller_session');
......@@ -277,14 +273,17 @@ class NewsletterController extends ActionController {
$this->view->assign('languageTemplates', $templates);
$this->view->assign('languageLabels', BackendService::getLanguageLabels($languages));
$this->view->assign('templates', $registerArray);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var RegisterService $registerService */
$registerService = $this->objectManager->get(RegisterService::class);
} else {
$registerService = GeneralUtility::makeInstance(RegisterService::class);
}
$registerService = $this->objectManager->get(RegisterService::class);
$this->view->assign(
'isManual', $registerService->isManuallyRegisteredTemplate($parameters['selectedTemplate'])
);
$templateDescription = $registerArray[$parameters['selectedExtension']][$parameters['selectedTemplate']]['description'];
if (\is_array($templateDescription)) {
if ($languages[0]['isocode']) {
$templateDescription = $templateDescription[$languages[0]['isocode']];
......@@ -329,23 +328,15 @@ class NewsletterController extends ActionController {
BackendService::makeButtons($this->docHeaderComponent, $this->request);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
/** @noinspection PhpInternalEntityUsedInspection */
$beUserMail = (!empty($arguments['emailAddress'])?$arguments['emailAddress']:$GLOBALS['BE_USER']->user['email']);
$this->view->assign('beUserMail', $beUserMail);
// get the default language label and pass it to the view
$pageTsConfig = BackendUtility::getPagesTSconfig($pageUid);
if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) {
$defaultLanguageLabel = LocalizationUtility::translate(
'LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage'
);
} else {
$defaultLanguageLabel = LocalizationUtility::translate(
'lll:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'
);
}
$defaultLanguageLabel = LocalizationUtility::translate(
'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage'
);
if (isset($pageTsConfig['mod.']['SHARED.']['defaultLanguageLabel'])) {
$defaultLanguageLabel = $pageTsConfig['mod.']['SHARED.']['defaultLanguageLabel'];
}
......@@ -418,20 +409,25 @@ class NewsletterController extends ActionController {
}
}
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var \SGalinski\SgMail\Service\MailTemplateService $mailTemplateService */
$mailTemplateService = $objectManager->get(
MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension']
);
$mailIsSend = FALSE;
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var \SGalinski\SgMail\Service\MailTemplateService $mailTemplateService */
$mailTemplateService = $objectManager->get(
MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension']
);
} else {
$mailTemplateService = GeneralUtility::makeInstance(
MailTemplateService::class, $parameters['selectedTemplate'], $parameters['selectedExtension']
);
}
$mailIsSend = FALSE;
$mailTemplateService->setTemplateName($parameters['selectedTemplate']);
$mailTemplateService->setExtensionKey($parameters['selectedExtension']);
$mailTemplateService->setFromName($parameter['fromName']);
$mailTemplateService->setFromAddress($parameter['fromMail']);
$mailTemplateService->setSubject($parameter['subject']);
$mailTemplateService->setReplyToAddress($parameter['replyTo']);
if (!$this->request->getArgument('sendRealEmails')) {
// Send test emails
$message = LocalizationUtility::translate('backend.success_mail', 'sg_mail');
......
......@@ -33,7 +33,6 @@ use SGalinski\SgMail\Session\PhpSession;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
......@@ -75,15 +74,6 @@ class QueueController extends ActionController {
*/
public function initializeView(ViewInterface $view) {
parent::initializeView($view);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsInlineCode(
'typo3_version', 'TYPO3.version='
. VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version())
. ';'
);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pageRenderer->loadExtJS();
}
$view->assign('controller', 'Queue');
}
......@@ -161,7 +151,6 @@ class QueueController extends ActionController {
$this->docHeaderComponent->setMetaInformation($pageInfo);
BackendService::makeButtons($this->docHeaderComponent, $this->request);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
}
......@@ -218,7 +207,13 @@ class QueueController extends ActionController {
*/
protected function initSessionAndTemplateFilter(array &$filters) {
if (!($this->session instanceof PhpSession)) {
$this->session = $this->objectManager->get(PhpSession::class);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var PhpSession session */
$this->session = $this->objectManager->get(PhpSession::class);
} else {
$this->session = GeneralUtility::makeInstance(PhpSession::class);
}
$this->session->setSessionKey('sg_mail_controller_session');
} else {
$this->session->setSessionKey('sg_mail_controller_session');
......
......@@ -26,55 +26,42 @@ namespace SGalinski\SgMail\Domain\Repository;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Page\PageRepository;
/**
* Abstract Repository
*/
abstract class AbstractRepository extends Repository {
/**
* Initializes the repository default settings
* AbstractRepository constructor.
*
* @return void
* @param ObjectManagerInterface $objectManager
*/
public function initializeObject() {
$querySettings = $this->objectManager->get(Typo3QuerySettings::class);
public function __construct(ObjectManagerInterface $objectManager) {
parent::__construct($objectManager);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.4.0', '<')) {
/** @var Typo3QuerySettings $querySettings */
$querySettings = $this->objectManager->get(Typo3QuerySettings::class);
} else {
$querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class);
}
$querySettings->setRespectStoragePage(FALSE);
if (TYPO3_MODE === 'BE') {
$querySettings->setIgnoreEnableFields(TRUE);
}