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 ;
1518use TYPO3 \CMS \Backend \Routing \Exception \RouteNotFoundException ;
1619use TYPO3 \CMS \Core \Utility \GeneralUtility ;
1720use TYPO3 \CMS \Extbase \Http \ForwardResponse ;
21+ use TYPO3 \CMS \Extbase \Mvc \Exception \NoSuchArgumentException ;
1822use TYPO3 \CMS \Extbase \Mvc \Exception \StopActionException ;
19- use TYPO3 \CMS \Extbase \Mvc \Exception \UnsupportedRequestTypeException ;
2023use TYPO3 \CMS \Extbase \Object \Exception ;
24+ use TYPO3 \CMS \Extbase \Pagination \QueryResultPaginator ;
2125use TYPO3 \CMS \Extbase \Persistence \Exception \InvalidQueryException ;
2226use TYPO3 \CMS \Extbase \Reflection \Exception \PropertyNotAccessibleException ;
2327
2630 */
2731class 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
0 commit comments