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 ;
16
19
use TYPO3 \CMS \Core \Utility \GeneralUtility ;
17
20
use TYPO3 \CMS \Extbase \Http \ForwardResponse ;
18
21
use TYPO3 \CMS \Extbase \Mvc \Exception \StopActionException ;
19
- use TYPO3 \CMS \Extbase \Mvc \Exception \UnsupportedRequestTypeException ;
20
22
use TYPO3 \CMS \Extbase \Object \Exception ;
23
+ use TYPO3 \CMS \Extbase \Pagination \QueryResultPaginator ;
21
24
use TYPO3 \CMS \Extbase \Persistence \Exception \InvalidQueryException ;
22
25
use TYPO3 \CMS \Extbase \Reflection \Exception \PropertyNotAccessibleException ;
23
26
26
29
*/
27
30
class ModuleController extends AbstractController
28
31
{
29
-
30
32
/**
31
33
* @param string $forwardToAction
32
34
* @throws StopActionException
@@ -50,23 +52,13 @@ public function listAction(): ResponseInterface
50
52
$ formUids = $ this ->mailRepository ->findGroupedFormUidsToGivenPageUid ((int )$ this ->id );
51
53
$ mails = $ this ->mailRepository ->findAllInPid ((int )$ this ->id , $ this ->settings , $ this ->piVars );
52
54
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
- );
55
+ $ currentPage = 1 ;
56
+ if ($ this ->request ->hasArgument ('currentPage ' )) {
57
+ $ currentPage = $ this ->request ->getArgument ('currentPage ' );
58
+ }
59
+ $ itemsPerPage = $ this ->settings ['perPage ' ] ?? 10 ;
60
+ $ paginator = GeneralUtility::makeInstance (QueryResultPaginator::class, $ mails , $ currentPage , $ itemsPerPage );
61
+ $ pagination = GeneralUtility::makeInstance (SlidingWindowPagination::class, $ paginator , 15 );
70
62
71
63
$ firstFormUid = StringUtility::conditionalVariable ($ this ->piVars ['filter ' ]['form ' ] ?? '' , key ($ formUids ));
72
64
$ beUser = BackendUtility::getBackendUserAuthentication ();
@@ -82,7 +74,7 @@ public function listAction(): ResponseInterface
82
74
'pagination ' => $ pagination ,
83
75
'paginator ' => $ paginator
84
76
],
85
- 'perPage ' => ( $ this ->settings ['perPage ' ] ? $ this -> settings [ ' perPage ' ] : 10 ) ,
77
+ 'perPage ' => $ this ->settings ['perPage ' ] ?? 10 ,
86
78
'writeAccess ' => $ beUser ->check ('tables_modify ' , Answer::TABLE_NAME )
87
79
&& $ beUser ->check ('tables_modify ' , Mail::TABLE_NAME ),
88
80
]
@@ -209,21 +201,17 @@ public function overviewBeAction(): ResponseInterface
209
201
210
202
/**
211
203
* @return void
212
- * @throws StopActionException
213
- * @noinspection PhpUnused
214
204
*/
215
205
public function initializeCheckBeAction (): void
216
206
{
217
207
$ this ->checkAdminPermissions ();
218
208
}
219
209
220
210
/**
221
- * @param string $email email address
222
- * @return void
223
- * @throws Exception
224
- * @noinspection PhpUnused
211
+ * @param string|null $email
212
+ * @return ResponseInterface
225
213
*/
226
- public function checkBeAction ($ email = null ): ResponseInterface
214
+ public function checkBeAction (string $ email = null ): ResponseInterface
227
215
{
228
216
$ this ->view ->assign ('pid ' , $ this ->id );
229
217
$ this ->sendTestEmail ($ email );
@@ -233,7 +221,6 @@ public function checkBeAction($email = null): ResponseInterface
233
221
/**
234
222
* @param null $email
235
223
* @return void
236
- * @throws Exception
237
224
*/
238
225
protected function sendTestEmail ($ email = null ): void
239
226
{
@@ -252,7 +239,6 @@ protected function sendTestEmail($email = null): void
252
239
253
240
/**
254
241
* @return void
255
- * @throws StopActionException
256
242
* @noinspection PhpUnused
257
243
*/
258
244
public function initializeConverterBeAction (): void
@@ -262,7 +248,6 @@ public function initializeConverterBeAction(): void
262
248
263
249
/**
264
250
* @return void
265
- * @throws StopActionException
266
251
* @noinspection PhpUnused
267
252
*/
268
253
public function initializeFixUploadFolderAction (): void
@@ -273,8 +258,7 @@ public function initializeFixUploadFolderAction(): void
273
258
/**
274
259
* @return void
275
260
* @throws StopActionException
276
- * @throws UnsupportedRequestTypeException
277
- * @throws \Exception
261
+ * @throws FileCannotBeCreatedException
278
262
* @noinspection PhpUnused
279
263
*/
280
264
public function fixUploadFolderAction (): void
@@ -285,7 +269,6 @@ public function fixUploadFolderAction(): void
285
269
286
270
/**
287
271
* @return void
288
- * @throws StopActionException
289
272
* @noinspection PhpUnused
290
273
*/
291
274
public function initializeFixWrongLocalizedFormsAction (): void
@@ -296,7 +279,7 @@ public function initializeFixWrongLocalizedFormsAction(): void
296
279
/**
297
280
* @return void
298
281
* @throws StopActionException
299
- * @throws UnsupportedRequestTypeException
282
+ * @throws DBALException
300
283
* @noinspection PhpUnused
301
284
*/
302
285
public function fixWrongLocalizedFormsAction (): void
@@ -307,7 +290,6 @@ public function fixWrongLocalizedFormsAction(): void
307
290
308
291
/**
309
292
* @return void
310
- * @throws StopActionException
311
293
* @noinspection PhpUnused
312
294
*/
313
295
public function initializeFixWrongLocalizedPagesAction (): void
0 commit comments