22declare (strict_types = 1 );
33namespace In2code \Powermail \Controller ;
44
5+ use Doctrine \DBAL \DBALException ;
56use In2code \Powermail \Domain \Model \Answer ;
67use In2code \Powermail \Domain \Model \Mail ;
78use In2code \Powermail \Domain \Repository \PageRepository ;
9+ use In2code \Powermail \Domain \Service \SlidingWindowPagination ;
10+ use In2code \Powermail \Exception \FileCannotBeCreatedException ;
811use In2code \Powermail \Utility \BackendUtility ;
912use In2code \Powermail \Utility \BasicFileUtility ;
1013use In2code \Powermail \Utility \ConfigurationUtility ;
1619use TYPO3 \CMS \Core \Utility \GeneralUtility ;
1720use TYPO3 \CMS \Extbase \Http \ForwardResponse ;
1821use TYPO3 \CMS \Extbase \Mvc \Exception \StopActionException ;
19- use TYPO3 \CMS \Extbase \Mvc \Exception \UnsupportedRequestTypeException ;
2022use TYPO3 \CMS \Extbase \Object \Exception ;
23+ use TYPO3 \CMS \Extbase \Pagination \QueryResultPaginator ;
2124use TYPO3 \CMS \Extbase \Persistence \Exception \InvalidQueryException ;
2225use TYPO3 \CMS \Extbase \Reflection \Exception \PropertyNotAccessibleException ;
2326
2629 */
2730class ModuleController extends AbstractController
2831{
29-
3032 /**
3133 * @param string $forwardToAction
3234 * @throws StopActionException
@@ -50,23 +52,13 @@ public function listAction(): ResponseInterface
5052 $ formUids = $ this ->mailRepository ->findGroupedFormUidsToGivenPageUid ((int )$ this ->id );
5153 $ mails = $ this ->mailRepository ->findAllInPid ((int )$ this ->id , $ this ->settings , $ this ->piVars );
5254
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 );
7062
7163 $ firstFormUid = StringUtility::conditionalVariable ($ this ->piVars ['filter ' ]['form ' ] ?? '' , key ($ formUids ));
7264 $ beUser = BackendUtility::getBackendUserAuthentication ();
@@ -82,7 +74,7 @@ public function listAction(): ResponseInterface
8274 'pagination ' => $ pagination ,
8375 'paginator ' => $ paginator
8476 ],
85- 'perPage ' => ( $ this ->settings ['perPage ' ] ? $ this -> settings [ ' perPage ' ] : 10 ) ,
77+ 'perPage ' => $ this ->settings ['perPage ' ] ?? 10 ,
8678 'writeAccess ' => $ beUser ->check ('tables_modify ' , Answer::TABLE_NAME )
8779 && $ beUser ->check ('tables_modify ' , Mail::TABLE_NAME ),
8880 ]
@@ -209,21 +201,17 @@ public function overviewBeAction(): ResponseInterface
209201
210202 /**
211203 * @return void
212- * @throws StopActionException
213- * @noinspection PhpUnused
214204 */
215205 public function initializeCheckBeAction (): void
216206 {
217207 $ this ->checkAdminPermissions ();
218208 }
219209
220210 /**
221- * @param string $email email address
222- * @return void
223- * @throws Exception
224- * @noinspection PhpUnused
211+ * @param string|null $email
212+ * @return ResponseInterface
225213 */
226- public function checkBeAction ($ email = null ): ResponseInterface
214+ public function checkBeAction (string $ email = null ): ResponseInterface
227215 {
228216 $ this ->view ->assign ('pid ' , $ this ->id );
229217 $ this ->sendTestEmail ($ email );
@@ -233,7 +221,6 @@ public function checkBeAction($email = null): ResponseInterface
233221 /**
234222 * @param null $email
235223 * @return void
236- * @throws Exception
237224 */
238225 protected function sendTestEmail ($ email = null ): void
239226 {
@@ -252,7 +239,6 @@ protected function sendTestEmail($email = null): void
252239
253240 /**
254241 * @return void
255- * @throws StopActionException
256242 * @noinspection PhpUnused
257243 */
258244 public function initializeConverterBeAction (): void
@@ -262,7 +248,6 @@ public function initializeConverterBeAction(): void
262248
263249 /**
264250 * @return void
265- * @throws StopActionException
266251 * @noinspection PhpUnused
267252 */
268253 public function initializeFixUploadFolderAction (): void
@@ -273,8 +258,7 @@ public function initializeFixUploadFolderAction(): void
273258 /**
274259 * @return void
275260 * @throws StopActionException
276- * @throws UnsupportedRequestTypeException
277- * @throws \Exception
261+ * @throws FileCannotBeCreatedException
278262 * @noinspection PhpUnused
279263 */
280264 public function fixUploadFolderAction (): void
@@ -285,7 +269,6 @@ public function fixUploadFolderAction(): void
285269
286270 /**
287271 * @return void
288- * @throws StopActionException
289272 * @noinspection PhpUnused
290273 */
291274 public function initializeFixWrongLocalizedFormsAction (): void
@@ -296,7 +279,7 @@ public function initializeFixWrongLocalizedFormsAction(): void
296279 /**
297280 * @return void
298281 * @throws StopActionException
299- * @throws UnsupportedRequestTypeException
282+ * @throws DBALException
300283 * @noinspection PhpUnused
301284 */
302285 public function fixWrongLocalizedFormsAction (): void
@@ -307,7 +290,6 @@ public function fixWrongLocalizedFormsAction(): void
307290
308291 /**
309292 * @return void
310- * @throws StopActionException
311293 * @noinspection PhpUnused
312294 */
313295 public function initializeFixWrongLocalizedPagesAction (): void
0 commit comments