Skip to content

Commit 5c09eff

Browse files
committed
Merge branch 'release/10.4.0'
2 parents d4d1dd6 + 770a2a6 commit 5c09eff

File tree

80 files changed

+605
-693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+605
-693
lines changed

Classes/Command/CleanupUnusedUploadsCommand.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44

55
use In2code\Powermail\Domain\Repository\AnswerRepository;
66
use In2code\Powermail\Utility\BasicFileUtility;
7-
use In2code\Powermail\Utility\ObjectUtility;
87
use Symfony\Component\Console\Command\Command;
98
use Symfony\Component\Console\Input\InputArgument;
109
use Symfony\Component\Console\Input\InputInterface;
1110
use Symfony\Component\Console\Output\OutputInterface;
1211
use TYPO3\CMS\Core\Utility\GeneralUtility;
13-
use TYPO3\CMS\Extbase\Object\Exception;
1412

1513
/**
1614
* Class CleanupUnusedUploadsCommand
@@ -32,7 +30,6 @@ public function configure()
3230
* @param InputInterface $input
3331
* @param OutputInterface $output
3432
* @return int
35-
* @throws Exception
3633
*/
3734
public function execute(InputInterface $input, OutputInterface $output): int
3835
{
@@ -56,11 +53,10 @@ public function execute(InputInterface $input, OutputInterface $output): int
5653

5754
/**
5855
* @return array
59-
* @throws Exception
6056
*/
61-
protected function getUsedUploads()
57+
protected function getUsedUploads(): array
6258
{
63-
$answerRepository = ObjectUtility::getObjectManager()->get(AnswerRepository::class);
59+
$answerRepository = GeneralUtility::makeInstance(AnswerRepository::class);
6460
$answers = $answerRepository->findByAnyUpload();
6561
$usedUploads = [];
6662
foreach ($answers as $answer) {

Classes/Command/ExportCommand.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
use In2code\Powermail\Domain\Repository\MailRepository;
66
use In2code\Powermail\Domain\Service\ExportService;
7-
use In2code\Powermail\Utility\ObjectUtility;
87
use Symfony\Component\Console\Command\Command;
98
use Symfony\Component\Console\Input\InputArgument;
109
use Symfony\Component\Console\Input\InputInterface;
1110
use Symfony\Component\Console\Output\OutputInterface;
11+
use TYPO3\CMS\Core\Utility\GeneralUtility;
1212
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
1313
use TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException;
14-
use TYPO3\CMS\Extbase\Object\Exception;
1514
use TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException;
1615

1716
/**
@@ -60,18 +59,17 @@ public function configure()
6059
* @return int
6160
* @throws InvalidConfigurationTypeException
6261
* @throws InvalidExtensionNameException
63-
* @throws Exception
6462
* @throws InvalidQueryException
6563
*/
6664
public function execute(InputInterface $input, OutputInterface $output): int
6765
{
68-
$mailRepository = ObjectUtility::getObjectManager()->get(MailRepository::class);
69-
$exportService = ObjectUtility::getObjectManager()->get(
66+
$mailRepository = GeneralUtility::makeInstance(MailRepository::class);
67+
$exportService = GeneralUtility::makeInstance(
7068
ExportService::class,
7169
$mailRepository->findAllInPid(
7270
(int)$input->getArgument('pageUid'),
7371
[],
74-
$this->getFilterVariables($input->getArgument('period'))
72+
$this->getFilterVariables((int)$input->getArgument('period'))
7573
),
7674
$input->getArgument('format'),
7775
['domain' => $input->getArgument('domain')]
@@ -99,7 +97,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
9997
* @param int $period
10098
* @return array
10199
*/
102-
protected function getFilterVariables($period)
100+
protected function getFilterVariables(int $period): array
103101
{
104102
$variables = ['filter' => []];
105103
if ($period > 0) {

Classes/Command/ResetMarkersCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
declare(strict_types = 1);
33
namespace In2code\Powermail\Command;
44

5+
use Doctrine\DBAL\DBALException;
56
use In2code\Powermail\Domain\Model\Field;
67
use In2code\Powermail\Domain\Service\GetNewMarkerNamesForFormService;
78
use In2code\Powermail\Utility\DatabaseUtility;
8-
use In2code\Powermail\Utility\ObjectUtility;
99
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Input\InputArgument;
1111
use Symfony\Component\Console\Input\InputInterface;
1212
use Symfony\Component\Console\Output\OutputInterface;
13+
use TYPO3\CMS\Core\Utility\GeneralUtility;
1314
use TYPO3\CMS\Extbase\Object\Exception;
1415

1516
/**
@@ -42,10 +43,11 @@ public function configure()
4243
* @param OutputInterface $output
4344
* @return int
4445
* @throws Exception
46+
* @throws DBALException
4547
*/
4648
public function execute(InputInterface $input, OutputInterface $output): int
4749
{
48-
$markerService = ObjectUtility::getObjectManager()->get(GetNewMarkerNamesForFormService::class);
50+
$markerService = GeneralUtility::makeInstance(GetNewMarkerNamesForFormService::class);
4951
$markers = $markerService->getMarkersForFieldsDependingOnForm(
5052
(int)$input->getArgument('formUid'),
5153
(bool)$input->getArgument('forceReset')

Classes/Controller/AbstractController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ protected function reformatParamsForAction(): void
191191

192192
// edit form: add answer id
193193
if (!empty($arguments['field']['__identity'])) {
194-
$answerRepository = $this->objectManager->get(AnswerRepository::class);
194+
$answerRepository = GeneralUtility::makeInstance(AnswerRepository::class);
195195
$answer = $answerRepository->findByFieldAndMail($fieldUid, $arguments['field']['__identity']);
196196
if ($answer !== null) {
197197
$newArguments['mail']['answers'][$iteration]['__identity'] = $answer->getUid();

Classes/Controller/FormController.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function createAction(Mail $mail, string $hash = ''): ResponseInterface
208208
if ($this->isNoOptin($mail, $hash)) {
209209
$this->sendMailPreflight($mail, $hash);
210210
} else {
211-
$mailPreflight = $this->objectManager->get(
211+
$mailPreflight = GeneralUtility::makeInstance(
212212
SendOptinConfirmationMailPreflight::class,
213213
$this->settings,
214214
$this->conf
@@ -224,7 +224,7 @@ public function createAction(Mail $mail, string $hash = ''): ResponseInterface
224224
$this->signalDispatch(__CLASS__, __FUNCTION__ . 'AfterSubmitView', [$mail, $hash, $this]);
225225
$this->prepareOutput($mail);
226226

227-
$finisherRunner = $this->objectManager->get(FinisherRunner::class);
227+
$finisherRunner = GeneralUtility::makeInstance(FinisherRunner::class);
228228
/** @noinspection PhpUnhandledExceptionInspection */
229229
$finisherRunner->callFinishers(
230230
$mail,
@@ -246,15 +246,15 @@ protected function sendMailPreflight(Mail $mail, string $hash = ''): void
246246
{
247247
try {
248248
if ($this->isSenderMailEnabled() && $this->mailRepository->getSenderMailFromArguments($mail)) {
249-
$mailPreflight = $this->objectManager->get(
249+
$mailPreflight = GeneralUtility::makeInstance(
250250
SendSenderMailPreflight::class,
251251
$this->settings,
252252
$this->conf
253253
);
254254
$mailPreflight->sendSenderMail($mail);
255255
}
256256
if ($this->isReceiverMailEnabled()) {
257-
$mailPreflight = $this->objectManager->get(SendReceiverMailPreflight::class, $this->settings);
257+
$mailPreflight = GeneralUtility::makeInstance(SendReceiverMailPreflight::class, $this->settings);
258258
$isSent = $mailPreflight->sendReceiverMail($mail, $hash);
259259
if ($isSent === false) {
260260
$this->addFlashMessage(
@@ -311,7 +311,7 @@ protected function prepareOutput(Mail $mail): void
311311
*/
312312
protected function saveMail(Mail $mail): void
313313
{
314-
$mailFactory = $this->objectManager->get(MailFactory::class);
314+
$mailFactory = GeneralUtility::makeInstance(MailFactory::class);
315315
$mailFactory->prepareMailForPersistence($mail, $this->settings);
316316
$this->mailRepository->add($mail);
317317
$this->persistenceManager->persistAll();
@@ -370,7 +370,11 @@ public function disclaimerAction(int $mail, string $hash): ResponseInterface
370370
$mail = $this->mailRepository->findByUid($mail);
371371
$status = false;
372372
if ($mail !== null && HashUtility::isHashValid($hash, $mail, 'disclaimer')) {
373-
$mailService = $this->objectManager->get(SendDisclaimedMailPreflight::class, $this->settings, $this->conf);
373+
$mailService = GeneralUtility::makeInstance(
374+
SendDisclaimedMailPreflight::class,
375+
$this->settings,
376+
$this->conf
377+
);
374378
$mailService->sendMail($mail);
375379
$this->mailRepository->removeFromDatabase($mail->getUid());
376380
$status = true;
@@ -415,7 +419,7 @@ public function initializeObject()
415419
{
416420
// @extensionScannerIgnoreLine Seems to be a false positive: getContentObject() is still correct in 9.0
417421
$this->contentObject = $this->configurationManager->getContentObject();
418-
$configurationService = $this->objectManager->get(ConfigurationService::class);
422+
$configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
419423
$this->conf = $configurationService->getTypoScriptConfiguration();
420424
$this->settings = ConfigurationUtility::mergeTypoScript2FlexForm($this->settings);
421425
if (ArrayUtility::isValidPath($this->settings, 'debug/settings') && $this->settings['debug']['settings']) {

Classes/Controller/ModuleController.php

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
declare(strict_types = 1);
33
namespace In2code\Powermail\Controller;
44

5+
use Doctrine\DBAL\DBALException;
56
use In2code\Powermail\Domain\Model\Answer;
67
use In2code\Powermail\Domain\Model\Mail;
78
use In2code\Powermail\Domain\Repository\PageRepository;
9+
use In2code\Powermail\Domain\Service\SlidingWindowPagination;
10+
use In2code\Powermail\Exception\FileCannotBeCreatedException;
811
use In2code\Powermail\Utility\BackendUtility;
912
use In2code\Powermail\Utility\BasicFileUtility;
1013
use In2code\Powermail\Utility\ConfigurationUtility;
@@ -15,9 +18,10 @@
1518
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
1619
use TYPO3\CMS\Core\Utility\GeneralUtility;
1720
use TYPO3\CMS\Extbase\Http\ForwardResponse;
21+
use TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException;
1822
use TYPO3\CMS\Extbase\Mvc\Exception\StopActionException;
19-
use TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException;
2023
use TYPO3\CMS\Extbase\Object\Exception;
24+
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;
2125
use TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException;
2226
use TYPO3\CMS\Extbase\Reflection\Exception\PropertyNotAccessibleException;
2327

@@ -26,47 +30,37 @@
2630
*/
2731
class ModuleController extends AbstractController
2832
{
29-
3033
/**
3134
* @param string $forwardToAction
3235
* @throws StopActionException
3336
* @return void
3437
* @noinspection PhpUnused
3538
*/
36-
public function dispatchAction($forwardToAction = 'list'): ResponseInterface
39+
public function dispatchAction(string $forwardToAction = 'list'): ResponseInterface
3740
{
3841
$this->forward($forwardToAction);
3942
return $this->htmlResponse();
4043
}
4144

4245
/**
43-
* @return void
46+
* @return ResponseInterface
4447
* @throws InvalidQueryException
4548
* @throws RouteNotFoundException
49+
* @throws NoSuchArgumentException
4650
* @noinspection PhpUnused
4751
*/
4852
public function listAction(): ResponseInterface
4953
{
5054
$formUids = $this->mailRepository->findGroupedFormUidsToGivenPageUid((int)$this->id);
5155
$mails = $this->mailRepository->findAllInPid((int)$this->id, $this->settings, $this->piVars);
5256

53-
$currentPage = $this->request->hasArgument('currentPage')
54-
? (int)$this->request->getArgument('currentPage')
55-
: 1;
56-
57-
$itemsPerPage = (int)$this->settings['perPage'] ? (int)$this->settings['perPage'] : 10;
58-
$maximumLinks = 15;
59-
60-
// Pagination for Mails
61-
$paginator = new \TYPO3\CMS\Extbase\Pagination\QueryResultPaginator(
62-
$mails,
63-
$currentPage,
64-
$itemsPerPage
65-
);
66-
$pagination = new \In2code\Powermail\Utility\SlidingWindowPagination(
67-
$paginator,
68-
$maximumLinks
69-
);
57+
$currentPage = 1;
58+
if ($this->request->hasArgument('currentPage')) {
59+
$currentPage = $this->request->getArgument('currentPage');
60+
}
61+
$itemsPerPage = $this->settings['perPage'] ?? 10;
62+
$paginator = GeneralUtility::makeInstance(QueryResultPaginator::class, $mails, $currentPage, $itemsPerPage);
63+
$pagination = GeneralUtility::makeInstance(SlidingWindowPagination::class, $paginator, 15);
7064

7165
$firstFormUid = StringUtility::conditionalVariable($this->piVars['filter']['form'] ?? '', key($formUids));
7266
$beUser = BackendUtility::getBackendUserAuthentication();
@@ -82,7 +76,7 @@ public function listAction(): ResponseInterface
8276
'pagination' => $pagination,
8377
'paginator' => $paginator
8478
],
85-
'perPage' => ($this->settings['perPage'] ? $this->settings['perPage'] : 10),
79+
'perPage' => $this->settings['perPage'] ?? 10,
8680
'writeAccess' => $beUser->check('tables_modify', Answer::TABLE_NAME)
8781
&& $beUser->check('tables_modify', Mail::TABLE_NAME),
8882
]
@@ -209,21 +203,17 @@ public function overviewBeAction(): ResponseInterface
209203

210204
/**
211205
* @return void
212-
* @throws StopActionException
213-
* @noinspection PhpUnused
214206
*/
215207
public function initializeCheckBeAction(): void
216208
{
217209
$this->checkAdminPermissions();
218210
}
219211

220212
/**
221-
* @param string $email email address
222-
* @return void
223-
* @throws Exception
224-
* @noinspection PhpUnused
213+
* @param string|null $email
214+
* @return ResponseInterface
225215
*/
226-
public function checkBeAction($email = null): ResponseInterface
216+
public function checkBeAction(string $email = null): ResponseInterface
227217
{
228218
$this->view->assign('pid', $this->id);
229219
$this->sendTestEmail($email);
@@ -233,7 +223,6 @@ public function checkBeAction($email = null): ResponseInterface
233223
/**
234224
* @param null $email
235225
* @return void
236-
* @throws Exception
237226
*/
238227
protected function sendTestEmail($email = null): void
239228
{
@@ -252,7 +241,6 @@ protected function sendTestEmail($email = null): void
252241

253242
/**
254243
* @return void
255-
* @throws StopActionException
256244
* @noinspection PhpUnused
257245
*/
258246
public function initializeConverterBeAction(): void
@@ -262,7 +250,6 @@ public function initializeConverterBeAction(): void
262250

263251
/**
264252
* @return void
265-
* @throws StopActionException
266253
* @noinspection PhpUnused
267254
*/
268255
public function initializeFixUploadFolderAction(): void
@@ -273,8 +260,7 @@ public function initializeFixUploadFolderAction(): void
273260
/**
274261
* @return void
275262
* @throws StopActionException
276-
* @throws UnsupportedRequestTypeException
277-
* @throws \Exception
263+
* @throws FileCannotBeCreatedException
278264
* @noinspection PhpUnused
279265
*/
280266
public function fixUploadFolderAction(): void
@@ -285,7 +271,6 @@ public function fixUploadFolderAction(): void
285271

286272
/**
287273
* @return void
288-
* @throws StopActionException
289274
* @noinspection PhpUnused
290275
*/
291276
public function initializeFixWrongLocalizedFormsAction(): void
@@ -296,7 +281,7 @@ public function initializeFixWrongLocalizedFormsAction(): void
296281
/**
297282
* @return void
298283
* @throws StopActionException
299-
* @throws UnsupportedRequestTypeException
284+
* @throws DBALException
300285
* @noinspection PhpUnused
301286
*/
302287
public function fixWrongLocalizedFormsAction(): void
@@ -307,7 +292,6 @@ public function fixWrongLocalizedFormsAction(): void
307292

308293
/**
309294
* @return void
310-
* @throws StopActionException
311295
* @noinspection PhpUnused
312296
*/
313297
public function initializeFixWrongLocalizedPagesAction(): void
@@ -318,12 +302,11 @@ public function initializeFixWrongLocalizedPagesAction(): void
318302
/**
319303
* @return void
320304
* @throws StopActionException
321-
* @throws UnsupportedRequestTypeException
322305
* @noinspection PhpUnused
323306
*/
324307
public function fixWrongLocalizedPagesAction(): void
325308
{
326-
$pageRepository = $this->objectManager->get(PageRepository::class);
309+
$pageRepository = GeneralUtility::makeInstance(PageRepository::class);
327310
$pageRepository->fixWrongLocalizedPages();
328311
$this->redirect('checkBe');
329312
}
@@ -333,7 +316,6 @@ public function fixWrongLocalizedPagesAction(): void
333316
* If not, forward to tools overview
334317
*
335318
* @return ResponseInterface|null
336-
* @throws StopActionException
337319
*/
338320
protected function checkAdminPermissions(): ?ResponseInterface
339321
{

0 commit comments

Comments
 (0)