33
33
use TYPO3 \CMS \Core \Imaging \Icon ;
34
34
use TYPO3 \CMS \Core \Imaging \IconFactory ;
35
35
use TYPO3 \CMS \Core \Localization \LanguageService ;
36
+ use TYPO3 \CMS \Core \Log \LogManager ;
36
37
use TYPO3 \CMS \Core \Messaging \AbstractMessage ;
37
38
use TYPO3 \CMS \Core \Page \JavaScriptModuleInstruction ;
38
39
use TYPO3 \CMS \Core \Page \PageRenderer ;
@@ -90,7 +91,24 @@ public function initializeAction(): void
90
91
*/
91
92
protected function initializeView (): void
92
93
{
94
+ $ apiStatus = [];
95
+ try {
96
+ $ checkStatus = $ this ->qbankService ->fetchMediaProperties ();
97
+ } catch (\Throwable $ th ) {
98
+ $ apiStatus = [
99
+ 'errorMessage ' => $ th ->getMessage (),
100
+ 'errorCode ' => $ th ->getCode (),
101
+ ];
102
+ $ logger = GeneralUtility::makeInstance (LogManager::class)->getLogger (__CLASS__ );
103
+ $ logger ->error (
104
+ sprintf (
105
+ 'Failed to connect to QBank API: "%s" ' ,
106
+ $ th ->getMessage ()
107
+ )
108
+ );
109
+ }
93
110
$ this ->moduleTemplate ->assignMultiple ([
111
+ 'apiStatus ' => $ apiStatus ,
94
112
'dateFormat ' => $ GLOBALS ['TYPO3_CONF_VARS ' ]['SYS ' ]['ddmmyy ' ],
95
113
'timeFormat ' => $ GLOBALS ['TYPO3_CONF_VARS ' ]['SYS ' ]['hhmm ' ],
96
114
'dateTimeFormat ' =>
@@ -192,7 +210,11 @@ protected function overviewAction(): ResponseInterface
192
210
{
193
211
$ this ->generateDropdownMenu ('overview ' );
194
212
$ this ->generateButtons ('overview ' );
195
- $ properties = $ this ->qbankService ->fetchMediaProperties ();
213
+ try {
214
+ $ properties = $ this ->qbankService ->fetchMediaProperties ();
215
+ } catch (\Throwable $ th ) {
216
+ $ properties = [];
217
+ }
196
218
$ this ->moduleTemplate ->assign ('properties ' , $ properties );
197
219
return $ this ->moduleTemplate ->renderResponse ('Management/Overview ' );
198
220
}
@@ -206,9 +228,14 @@ protected function mappingsAction(): ResponseInterface
206
228
$ this ->generateButtons ('mappings ' );
207
229
$ mappingRepository = GeneralUtility::makeInstance (MappingRepository::class);
208
230
$ mappings = $ mappingRepository ->findAll ();
231
+ try {
232
+ $ mediaProperties = $ this ->qbankService ->fetchMediaProperties ();
233
+ } catch (\Throwable $ th ) {
234
+ $ mediaProperties = [];
235
+ }
209
236
$ this ->moduleTemplate ->assignMultiple ([
210
237
'mappings ' => $ mappings ,
211
- 'mediaProperties ' => $ this -> qbankService -> fetchMediaProperties () ,
238
+ 'mediaProperties ' => $ mediaProperties ,
212
239
'fileProperties ' => PropertyUtility::getFileProperties (),
213
240
]);
214
241
return $ this ->moduleTemplate ->renderResponse ('Management/Mappings ' );
0 commit comments