2
2
declare (strict_types = 1 );
3
3
namespace In2code \Powermail \Controller ;
4
4
5
+ use Doctrine \DBAL \DBALException ;
5
6
use In2code \Powermail \Domain \Model \Answer ;
6
7
use In2code \Powermail \Domain \Model \Mail ;
7
8
use In2code \Powermail \Domain \Repository \PageRepository ;
9
+ use In2code \Powermail \Domain \Service \SlidingWindowPagination ;
10
+ use In2code \Powermail \Exception \FileCannotBeCreatedException ;
8
11
use In2code \Powermail \Utility \BackendUtility ;
9
12
use In2code \Powermail \Utility \BasicFileUtility ;
10
13
use In2code \Powermail \Utility \ConfigurationUtility ;
15
18
use TYPO3 \CMS \Backend \Routing \Exception \RouteNotFoundException ;
16
19
use TYPO3 \CMS \Core \Utility \GeneralUtility ;
17
20
use TYPO3 \CMS \Extbase \Http \ForwardResponse ;
21
+ use TYPO3 \CMS \Extbase \Mvc \Exception \NoSuchArgumentException ;
18
22
use TYPO3 \CMS \Extbase \Mvc \Exception \StopActionException ;
19
- use TYPO3 \CMS \Extbase \Mvc \Exception \UnsupportedRequestTypeException ;
20
23
use TYPO3 \CMS \Extbase \Object \Exception ;
24
+ use TYPO3 \CMS \Extbase \Pagination \QueryResultPaginator ;
21
25
use TYPO3 \CMS \Extbase \Persistence \Exception \InvalidQueryException ;
22
26
use TYPO3 \CMS \Extbase \Reflection \Exception \PropertyNotAccessibleException ;
23
27
26
30
*/
27
31
class ModuleController extends AbstractController
28
32
{
29
-
30
33
/**
31
34
* @param string $forwardToAction
32
35
* @throws StopActionException
33
36
* @return void
34
37
* @noinspection PhpUnused
35
38
*/
36
- public function dispatchAction ($ forwardToAction = 'list ' ): ResponseInterface
39
+ public function dispatchAction (string $ forwardToAction = 'list ' ): ResponseInterface
37
40
{
38
41
$ this ->forward ($ forwardToAction );
39
42
return $ this ->htmlResponse ();
40
43
}
41
44
42
45
/**
43
- * @return void
46
+ * @return ResponseInterface
44
47
* @throws InvalidQueryException
45
48
* @throws RouteNotFoundException
49
+ * @throws NoSuchArgumentException
46
50
* @noinspection PhpUnused
47
51
*/
48
52
public function listAction (): ResponseInterface
49
53
{
50
54
$ formUids = $ this ->mailRepository ->findGroupedFormUidsToGivenPageUid ((int )$ this ->id );
51
55
$ mails = $ this ->mailRepository ->findAllInPid ((int )$ this ->id , $ this ->settings , $ this ->piVars );
52
56
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 );
70
64
71
65
$ firstFormUid = StringUtility::conditionalVariable ($ this ->piVars ['filter ' ]['form ' ] ?? '' , key ($ formUids ));
72
66
$ beUser = BackendUtility::getBackendUserAuthentication ();
@@ -82,7 +76,7 @@ public function listAction(): ResponseInterface
82
76
'pagination ' => $ pagination ,
83
77
'paginator ' => $ paginator
84
78
],
85
- 'perPage ' => ( $ this ->settings ['perPage ' ] ? $ this -> settings [ ' perPage ' ] : 10 ) ,
79
+ 'perPage ' => $ this ->settings ['perPage ' ] ?? 10 ,
86
80
'writeAccess ' => $ beUser ->check ('tables_modify ' , Answer::TABLE_NAME )
87
81
&& $ beUser ->check ('tables_modify ' , Mail::TABLE_NAME ),
88
82
]
@@ -209,21 +203,17 @@ public function overviewBeAction(): ResponseInterface
209
203
210
204
/**
211
205
* @return void
212
- * @throws StopActionException
213
- * @noinspection PhpUnused
214
206
*/
215
207
public function initializeCheckBeAction (): void
216
208
{
217
209
$ this ->checkAdminPermissions ();
218
210
}
219
211
220
212
/**
221
- * @param string $email email address
222
- * @return void
223
- * @throws Exception
224
- * @noinspection PhpUnused
213
+ * @param string|null $email
214
+ * @return ResponseInterface
225
215
*/
226
- public function checkBeAction ($ email = null ): ResponseInterface
216
+ public function checkBeAction (string $ email = null ): ResponseInterface
227
217
{
228
218
$ this ->view ->assign ('pid ' , $ this ->id );
229
219
$ this ->sendTestEmail ($ email );
@@ -233,7 +223,6 @@ public function checkBeAction($email = null): ResponseInterface
233
223
/**
234
224
* @param null $email
235
225
* @return void
236
- * @throws Exception
237
226
*/
238
227
protected function sendTestEmail ($ email = null ): void
239
228
{
@@ -252,7 +241,6 @@ protected function sendTestEmail($email = null): void
252
241
253
242
/**
254
243
* @return void
255
- * @throws StopActionException
256
244
* @noinspection PhpUnused
257
245
*/
258
246
public function initializeConverterBeAction (): void
@@ -262,7 +250,6 @@ public function initializeConverterBeAction(): void
262
250
263
251
/**
264
252
* @return void
265
- * @throws StopActionException
266
253
* @noinspection PhpUnused
267
254
*/
268
255
public function initializeFixUploadFolderAction (): void
@@ -273,8 +260,7 @@ public function initializeFixUploadFolderAction(): void
273
260
/**
274
261
* @return void
275
262
* @throws StopActionException
276
- * @throws UnsupportedRequestTypeException
277
- * @throws \Exception
263
+ * @throws FileCannotBeCreatedException
278
264
* @noinspection PhpUnused
279
265
*/
280
266
public function fixUploadFolderAction (): void
@@ -285,7 +271,6 @@ public function fixUploadFolderAction(): void
285
271
286
272
/**
287
273
* @return void
288
- * @throws StopActionException
289
274
* @noinspection PhpUnused
290
275
*/
291
276
public function initializeFixWrongLocalizedFormsAction (): void
@@ -296,7 +281,7 @@ public function initializeFixWrongLocalizedFormsAction(): void
296
281
/**
297
282
* @return void
298
283
* @throws StopActionException
299
- * @throws UnsupportedRequestTypeException
284
+ * @throws DBALException
300
285
* @noinspection PhpUnused
301
286
*/
302
287
public function fixWrongLocalizedFormsAction (): void
@@ -307,7 +292,6 @@ public function fixWrongLocalizedFormsAction(): void
307
292
308
293
/**
309
294
* @return void
310
- * @throws StopActionException
311
295
* @noinspection PhpUnused
312
296
*/
313
297
public function initializeFixWrongLocalizedPagesAction (): void
0 commit comments