Skip to content

Commit

Permalink
Merge pull request #64 from pluswerk/bugfix/configurationManager
Browse files Browse the repository at this point in the history
use backend ConfigurationManager to avoid problems with instantiation…
  • Loading branch information
CamillH authored Jan 7, 2025
2 parents 49c18cb + 1146130 commit 33404da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Classes/Domain/Repository/MailLogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private function cleanupDatabase(): void
if ($this->lifetime !== '') {
$deletionTimestamp = strtotime('-' . $this->lifetime);
if ($deletionTimestamp === false) {
throw new Exception(sprintf('Given lifetime string in TypoScript is wrong. lifetime: "%s"', $this->lifetime));
throw new Exception(sprintf('Given lifetime string in TypoScript is wrong. lifetime: "%s"', $this->lifetime), 6909750626);
}

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_maillogger_domain_model_maillog');
Expand All @@ -98,7 +98,7 @@ private function anonymizeAll(): void
if ($this->anonymize) {
$timestamp = strtotime('-' . $this->anonymizeAfter);
if ($timestamp === false) {
throw new Exception(sprintf('Given lifetime string in TypoScript is wrong. anonymize: "%s"', $this->anonymizeAfter));
throw new Exception(sprintf('Given lifetime string in TypoScript is wrong. anonymize: "%s"', $this->anonymizeAfter), 2071153190);
}

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_maillogger_domain_model_maillog');
Expand Down Expand Up @@ -153,7 +153,7 @@ public function update($mailLog): void
private function anonymizeMailLogIfNeeded(MailLog $mailLog): void
{
if ($mailLog->getCrdate() === null) {
throw new InvalidArgumentException('MailLog must have a crdate');
throw new InvalidArgumentException('MailLog must have a crdate', 2957168920);
}

if (!$this->anonymize) {
Expand Down
8 changes: 4 additions & 4 deletions Classes/Utility/ConfigurationUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Exception;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;

class ConfigurationUtility
Expand All @@ -20,14 +21,13 @@ class ConfigurationUtility
public static function getCurrentModuleConfiguration(string $key): array
{
if (!self::$currentModuleConfiguration) {
$configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class);

$fullTypoScript = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
// we always use the BackendConfigurationManager, because flux is overwriting the ConfigurationManager and always uses the FrontendConfigurationManager instead of the correct one for the current context
$fullTypoScript = GeneralUtility::makeInstance(BackendConfigurationManager::class)->getTypoScriptSetup();

$typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);

if (empty($fullTypoScript['module.']['tx_maillogger.'])) {
throw new Exception('Constants and setup TypoScript are not included!');
throw new Exception('Constants and setup TypoScript are not included!', 6970880062);
}

self::$currentModuleConfiguration = $typoScriptService->convertTypoScriptArrayToPlainArray($fullTypoScript['module.']['tx_maillogger.']);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Utility/MailUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function getMailByKey(string $key, int $languageUid = null, array
$templateRepository = GeneralUtility::makeInstance(MailTemplateRepository::class);
$mailTemplate = $templateRepository->findOneByTypoScriptKeyAndLanguage($key, $languageUid);
if (!$mailTemplate) {
throw new Exception('No "MailTemplate" was found for key "' . $key . '". Please check your database records!');
throw new Exception('No "MailTemplate" was found for key "' . $key . '". Please check your database records!', 2058250013);
}

return $mail->setMailTemplate($mailTemplate, true, $viewParameters);
Expand All @@ -47,7 +47,7 @@ public static function getMailById(int $mailTemplateId, array $viewParameters =
$templateRepository = GeneralUtility::makeInstance(MailTemplateRepository::class);
$mailTemplate = $templateRepository->findByUid($mailTemplateId);
if (!$mailTemplate) {
throw new Exception('No "MailTemplate" was found for uid "' . $mailTemplateId . '". Please check your database records!');
throw new Exception('No "MailTemplate" was found for uid "' . $mailTemplateId . '". Please check your database records!', 1734605832);
}

return $mail->setMailTemplate($mailTemplate, true, $viewParameters);
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"require-dev": {
"ext-json": "*",
"pluswerk/grumphp-config": "^7.1.0",
"saschaegerer/phpstan-typo3": "^1.10.1",
"saschaegerer/phpstan-typo3": "^1.10.2",
"spatie/phpunit-snapshot-assertions": "^4.2.17",
"ssch/typo3-rector": "^2.6.4",
"typo3/testing-framework": "^7.1.0"
"ssch/typo3-rector": "^2.12.2",
"typo3/testing-framework": "^7.1.1"
},
"replace": {
"pluswerk/mail_logger": "self.version",
Expand Down

0 comments on commit 33404da

Please sign in to comment.