Skip to content

Commit d40def4

Browse files
committed
Merge branch 'release/10.3.0'
2 parents ab5d4ad + e07678d commit d40def4

File tree

15 files changed

+716
-717
lines changed

15 files changed

+716
-717
lines changed

Classes/Domain/Model/Mail.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
declare(strict_types = 1);
33
namespace In2code\Powermail\Domain\Model;
44

5+
use DateTime;
56
use In2code\Powermail\Utility\ArrayUtility;
67
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
78
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
@@ -77,7 +78,7 @@ class Mail extends AbstractEntity
7778
protected $answers = null;
7879

7980
/**
80-
* @var \DateTime
81+
* @var DateTime
8182
*/
8283
protected $crdate = null;
8384

@@ -401,18 +402,18 @@ public function removeAnswer(Answer $answerToRemove): void
401402
}
402403

403404
/**
404-
* @return \DateTime
405+
* @return DateTime|null
405406
*/
406-
public function getCrdate(): \DateTime
407+
public function getCrdate(): ?DateTime
407408
{
408409
return $this->crdate;
409410
}
410411

411412
/**
412-
* @param \DateTime $crdate
413+
* @param DateTime $crdate
413414
* @return Mail
414415
*/
415-
public function setCrdate(\DateTime $crdate): Mail
416+
public function setCrdate(DateTime $crdate): Mail
416417
{
417418
$this->crdate = $crdate;
418419
return $this;

Classes/Domain/Repository/AnswerRepository.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
*/
1111
class AnswerRepository extends AbstractRepository
1212
{
13-
1413
/**
1514
* Find single Answer by field uid and mail uid
1615
*
1716
* @param int $fieldUid
1817
* @param int $mailUid
19-
* @return Answer
18+
* @return Answer|null
2019
*/
21-
public function findByFieldAndMail($fieldUid, $mailUid): Answer
20+
public function findByFieldAndMail($fieldUid, $mailUid): ?Answer
2221
{
2322
$query = $this->createQuery();
2423
$query->getQuerySettings()->setRespectStoragePage(false);

Classes/Domain/Service/Mail/SendMailService.php

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
use In2code\Powermail\Utility\TypoScriptUtility;
1515
use TYPO3\CMS\Core\Mail\MailMessage;
1616
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
17+
use TYPO3\CMS\Core\Utility\ArrayUtility as ArrayUtilityCore;
1718
use TYPO3\CMS\Core\Utility\GeneralUtility;
1819
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
19-
use TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerNameException;
2020
use TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException;
2121
use TYPO3\CMS\Extbase\Object\Exception;
2222
use TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException;
@@ -73,7 +73,6 @@ class SendMailService
7373
* @param string $type Email to "sender" or "receiver"
7474
* @return bool Mail successfully sent
7575
* @throws InvalidConfigurationTypeException
76-
* @throws InvalidControllerNameException
7776
* @throws InvalidExtensionNameException
7877
* @throws InvalidSlotException
7978
* @throws InvalidSlotReturnException
@@ -102,15 +101,14 @@ public function sendMail(array $email, Mail $mail, array $settings, string $type
102101
* @param array $email
103102
* @return bool
104103
* @throws InvalidConfigurationTypeException
105-
* @throws InvalidControllerNameException
106104
* @throws InvalidExtensionNameException
107105
* @throws InvalidSlotException
108106
* @throws InvalidSlotReturnException
109107
* @throws Exception
110108
*/
111109
protected function prepareAndSend(array $email): bool
112110
{
113-
$message = ObjectUtility::getObjectManager()->get(MailMessage::class);
111+
$message = GeneralUtility::makeInstance(MailMessage::class);
114112
$message
115113
->setTo([$email['receiverEmail'] => $email['receiverName']])
116114
->setFrom([$email['senderEmail'] => $email['senderName']])
@@ -156,8 +154,8 @@ protected function prepareAndSend(array $email): bool
156154
protected function addCc(MailMessage $message): MailMessage
157155
{
158156
$ccValue = ObjectUtility::getContentObject()->cObjGetSingle(
159-
$this->overwriteConfig['cc']??'',
160-
$this->overwriteConfig['cc.']??[]
157+
$this->overwriteConfig['cc'] ?? '',
158+
$this->overwriteConfig['cc.'] ?? []
161159
);
162160
if (!empty($ccValue)) {
163161
$message->setCc(GeneralUtility::trimExplode(',', $ccValue, true));
@@ -175,8 +173,8 @@ protected function addCc(MailMessage $message): MailMessage
175173
protected function addBcc(MailMessage $message): MailMessage
176174
{
177175
$bccValue = ObjectUtility::getContentObject()->cObjGetSingle(
178-
$this->overwriteConfig['bcc']??'',
179-
$this->overwriteConfig['bcc.']??[]
176+
$this->overwriteConfig['bcc'] ?? '',
177+
$this->overwriteConfig['bcc.'] ?? []
180178
);
181179
if (!empty($bccValue)) {
182180
$message->setBcc(GeneralUtility::trimExplode(',', $bccValue, true));
@@ -194,8 +192,8 @@ protected function addBcc(MailMessage $message): MailMessage
194192
protected function addReturnPath(MailMessage $message): MailMessage
195193
{
196194
$returnPathValue = ObjectUtility::getContentObject()->cObjGetSingle(
197-
$this->overwriteConfig['returnPath']??'',
198-
$this->overwriteConfig['returnPath.']??[]
195+
$this->overwriteConfig['returnPath'] ?? '',
196+
$this->overwriteConfig['returnPath.'] ?? []
199197
);
200198
if (!empty($returnPathValue)) {
201199
$message->setReturnPath($returnPathValue);
@@ -221,11 +219,7 @@ protected function addReplyAddresses(MailMessage $message): MailMessage
221219
$this->overwriteConfig['replyToName.']??[]
222220
);
223221
if (!empty($replyToEmail) && !empty($replyToName)) {
224-
$message->setReplyTo(
225-
[
226-
$replyToEmail => $replyToName
227-
]
228-
);
222+
$message->setReplyTo([$replyToEmail => $replyToName]);
229223
}
230224
return $message;
231225
}
@@ -260,7 +254,7 @@ protected function addAttachmentsFromUploads(MailMessage $message): MailMessage
260254
{
261255
if (!empty($this->settings[$this->type]['attachment']) && !empty($this->settings['misc']['file']['folder'])) {
262256
/** @var UploadService $uploadService */
263-
$uploadService = ObjectUtility::getObjectManager()->get(UploadService::class);
257+
$uploadService = GeneralUtility::makeInstance(UploadService::class);
264258
foreach ($uploadService->getFiles() as $file) {
265259
if ($file->isUploaded() && $file->isValid() && $file->isFileExisting()) {
266260
$message->attachFromPath($file->getNewPathAndFilename(true));
@@ -303,7 +297,6 @@ protected function addAttachmentsFromTypoScript(MailMessage $message): MailMessa
303297
* @param array $email
304298
* @return MailMessage
305299
* @throws InvalidConfigurationTypeException
306-
* @throws InvalidControllerNameException
307300
* @throws InvalidExtensionNameException
308301
* @throws InvalidSlotException
309302
* @throws InvalidSlotReturnException
@@ -322,7 +315,6 @@ protected function addHtmlBody(MailMessage $message, array $email): MailMessage
322315
* @param array $email
323316
* @return MailMessage
324317
* @throws InvalidConfigurationTypeException
325-
* @throws InvalidControllerNameException
326318
* @throws InvalidExtensionNameException
327319
* @throws InvalidSlotException
328320
* @throws InvalidSlotReturnException
@@ -331,7 +323,7 @@ protected function addHtmlBody(MailMessage $message, array $email): MailMessage
331323
protected function addPlainBody(MailMessage $message, array $email): MailMessage
332324
{
333325
if ($email['format'] !== 'html') {
334-
$plaintextService = ObjectUtility::getObjectManager()->get(PlaintextService::class);
326+
$plaintextService = GeneralUtility::makeInstance(PlaintextService::class);
335327
$message->text($plaintextService->makePlain($this->createEmailBody($email)), FrontendUtility::getCharset());
336328
}
337329
return $message;
@@ -372,7 +364,6 @@ protected function addSenderHeader(MailMessage $message): MailMessage
372364
/**
373365
* @param array $email
374366
* @return string
375-
* @throws InvalidControllerNameException
376367
* @throws InvalidSlotException
377368
* @throws InvalidSlotReturnException
378369
* @throws InvalidConfigurationTypeException
@@ -386,7 +377,7 @@ protected function createEmailBody(array $email): string
386377
$standaloneView->setTemplatePathAndFilename(TemplateUtility::getTemplatePath($email['template'] . '.html'));
387378

388379
// variables
389-
$mailRepository = ObjectUtility::getObjectManager()->get(MailRepository::class);
380+
$mailRepository = GeneralUtility::makeInstance(MailRepository::class);
390381
$variablesWithMarkers = $mailRepository->getVariablesWithMarkersFromMail($this->mail);
391382
$standaloneView->assignMultiple($variablesWithMarkers);
392383
$standaloneView->assignMultiple($mailRepository->getLabelsWithMarkersFromMail($this->mail));
@@ -429,11 +420,10 @@ protected function updateMail(array $email): void
429420
/**
430421
* @param array $settings
431422
* @return array
432-
* @throws Exception
433423
*/
434424
protected function getConfigurationFromSettings(array $settings): array
435425
{
436-
$typoScriptService = ObjectUtility::getObjectManager()->get(TypoScriptService::class);
426+
$typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
437427
return $typoScriptService->convertPlainArrayToTypoScriptArray($settings);
438428
}
439429

@@ -449,7 +439,7 @@ protected function getConfigurationFromSettings(array $settings): array
449439
*/
450440
protected function parseAndOverwriteVariables(array &$email, Mail $mail): void
451441
{
452-
$mailRepository = ObjectUtility::getObjectManager()->get(MailRepository::class);
442+
$mailRepository = GeneralUtility::makeInstance(MailRepository::class);
453443
$email['subject'] = TypoScriptUtility::overwriteValueFromTypoScript(
454444
$email['subject'],
455445
$this->overwriteConfig,
@@ -507,10 +497,10 @@ protected function initialize(Mail $mail, array $settings, string $type): void
507497
$this->mail = $mail;
508498
$this->settings = $settings;
509499
$this->configuration = $this->getConfigurationFromSettings($settings);
510-
if (\TYPO3\CMS\Core\Utility\ArrayUtility::isValidPath($this->configuration, $type . './overwrite')) {
500+
if (ArrayUtilityCore::isValidPath($this->configuration, $type . './overwrite.')) {
511501
$this->overwriteConfig = $this->configuration[$type . '.']['overwrite.'];
512502
}
513-
$mailRepository = ObjectUtility::getObjectManager()->get(MailRepository::class);
503+
$mailRepository = GeneralUtility::makeInstance(MailRepository::class);
514504
ObjectUtility::getContentObject()->start($mailRepository->getVariablesWithMarkersFromMail($mail));
515505
$this->type = $type;
516506
}

Classes/Finisher/FinisherRunner.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@
55
use In2code\Powermail\Domain\Model\Mail;
66
use In2code\Powermail\Exception\ClassDoesNotExistException;
77
use In2code\Powermail\Exception\InterfaceNotImplementedException;
8-
use In2code\Powermail\Utility\ObjectUtility;
98
use In2code\Powermail\Utility\StringUtility;
10-
use TYPO3\CMS\Extbase\Object\Exception;
9+
use TYPO3\CMS\Core\Utility\GeneralUtility;
1110
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
1211

1312
/**
1413
* Class FinisherRunner
1514
*/
1615
class FinisherRunner
1716
{
18-
1917
/**
2018
* @var string
2119
*/
22-
protected $interface = 'In2code\Powermail\Finisher\FinisherInterface';
20+
protected $interface = FinisherInterface::class;
2321

2422
/**
2523
* Call finisher classes after submit
@@ -32,7 +30,6 @@ class FinisherRunner
3230
* @return void
3331
* @throws ClassDoesNotExistException
3432
* @throws InterfaceNotImplementedException
35-
* @throws Exception
3633
*/
3734
public function callFinishers(
3835
Mail $mail,
@@ -51,17 +48,11 @@ public function callFinishers(
5148
);
5249
}
5350
if (is_subclass_of($class, $this->interface)) {
54-
if (!isset($dpSettings['config'])) {
55-
$finisherSettings['config'] = [];
56-
} else {
57-
$finisherSettings['config'] = (array)$finisherSettings['config'];
58-
}
59-
6051
/** @var AbstractFinisher $finisher */
61-
$finisher = ObjectUtility::getObjectManager()->get(
52+
$finisher = GeneralUtility::makeInstance(
6253
$class,
6354
$mail,
64-
$finisherSettings['config'],
55+
(array)$finisherSettings['config'] ?? [],
6556
$settings,
6657
$formSubmitted,
6758
$actionMethodName,

Classes/Tca/ShowFormNoteEditForm.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
declare(strict_types = 1);
33
namespace In2code\Powermail\Tca;
44

5+
use Doctrine\DBAL\DBALException;
56
use In2code\Powermail\Domain\Model\Field;
67
use In2code\Powermail\Domain\Model\Form;
78
use In2code\Powermail\Domain\Model\Page;
@@ -48,8 +49,7 @@ class ShowFormNoteEditForm extends AbstractFormElement
4849
/**
4950
* Show Note which form was selected
5051
*
51-
* @param array $params TCA configuration array
52-
* @return string
52+
* @return array
5353
* @throws DeprecatedException
5454
* @throws Exception
5555
* @throws ExtensionConfigurationExtensionNotConfiguredException
@@ -98,7 +98,7 @@ protected function getHtml(): string
9898
*/
9999
protected function getLabels(): array
100100
{
101-
$labels = [
101+
return [
102102
'formname' => $this->getLabel('formnote.formname'),
103103
'storedinpage' => $this->getLabel('formnote.storedinpage'),
104104
'pages' => $this->getLabel('formnote.pages'),
@@ -107,7 +107,6 @@ protected function getLabels(): array
107107
'new' => $this->getLabel('formnote.new'),
108108
'edit' => $this->getLabel('formnote.edit')
109109
];
110-
return $labels;
111110
}
112111

113112
/**
@@ -221,9 +220,10 @@ protected function getFormProperties(): array
221220
*/
222221
protected function getRelatedFormUid(): int
223222
{
224-
$flexFormArray = (array)$this->data['databaseRow']['pi_flexform']['data']['main']['lDEF'];
223+
$flexFormArray = (array)$this->data['databaseRow']['pi_flexform']['data']['main']['lDEF'] ?? [];
225224
$formUid = (int)($flexFormArray['settings.flexform.main.form']['vDEF'][0] ?? 0);
226-
$language = (int)($this->data['databaseRow']['sys_language_uid'][0] ?? $this->data['databaseRow']['sys_language_uid'] ?? 0);
225+
$language = (int)($this->data['databaseRow']['sys_language_uid'][0]
226+
?? $this->data['databaseRow']['sys_language_uid'] ?? 0);
227227
$formUid = $this->getLocalizedFormUid($formUid, $language);
228228
return $formUid;
229229
}
@@ -255,6 +255,7 @@ protected function getStoragePageProperties(): array
255255
* @return array
256256
* @throws ExtensionConfigurationExtensionNotConfiguredException
257257
* @throws ExtensionConfigurationPathDoesNotExistException
258+
* @throws DBALException
258259
*/
259260
protected function getRelatedPages(): array
260261
{
@@ -282,6 +283,7 @@ protected function getRelatedPages(): array
282283
* if replaceIrreWithElementBrowser is active
283284
*
284285
* @return array
286+
* @throws DBALException
285287
*/
286288
protected function getRelatedPagesAlternative(): array
287289
{
@@ -316,6 +318,7 @@ protected function getRelatedPagesAlternative(): array
316318
* @return array
317319
* @throws ExtensionConfigurationExtensionNotConfiguredException
318320
* @throws ExtensionConfigurationPathDoesNotExistException
321+
* @throws DBALException
319322
*/
320323
protected function getRelatedFields(): array
321324
{
@@ -348,6 +351,7 @@ protected function getRelatedFields(): array
348351
* if replaceIrreWithElementBrowser is active
349352
*
350353
* @return array
354+
* @throws DBALException
351355
*/
352356
protected function getRelatedFieldsAlternative(): array
353357
{

0 commit comments

Comments
 (0)