AdministrationController   B
last analyzed

Complexity

Total Complexity 46

Size/Duplication

Total Lines 453
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 204
dl 0
loc 453
rs 8.72
c 0
b 0
f 0
wmc 46

27 Methods

Rating   Name   Duplication   Size   Complexity  
A injectIconFactory() 0 3 1
A injectMaintenanceService() 0 3 1
A injectBeUserSessionService() 0 3 1
A initializeAction() 0 3 1
A injectCustomNotificationLogRepository() 0 4 1
A initializeListAction() 0 5 2
A injectExportService() 0 3 1
A injectSettingsService() 0 3 1
A injectModuleTemplateFactory() 0 3 1
A injectPageRenderer() 0 3 1
A registerDocHeaderButtons() 0 51 3
A indexNotifyAction() 0 24 2
A exportAction() 0 8 3
A isResetFilter() 0 8 2
A settingsErrorAction() 0 3 1
A notifyAction() 0 19 2
A getOrderByFields() 0 6 1
A getNotificationRecipients() 0 31 1
A getOrderDirections() 0 5 1
A getBackendUser() 0 3 1
A getCreateNewRecordUri() 0 16 5
B listAction() 0 70 7
A getLanguageService() 0 3 1
A handleExpiredRegistrationsAction() 0 11 1
A checkEventAccess() 0 12 2
A getErrorFlashMessage() 0 3 1
A initModuleTemplateAndReturnResponse() 0 22 1

How to fix   Complexity   

Complex Class

Complex classes like AdministrationController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use AdministrationController, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\Controller;
13
14
use DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification;
15
use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand;
16
use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand;
17
use DERHANSEN\SfEventMgt\Domain\Model\Event;
18
use DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository;
19
use DERHANSEN\SfEventMgt\Event\InitAdministrationModuleTemplateEvent;
20
use DERHANSEN\SfEventMgt\Event\ModifyAdministrationIndexNotifyViewVariablesEvent;
21
use DERHANSEN\SfEventMgt\Event\ModifyAdministrationListViewVariablesEvent;
22
use DERHANSEN\SfEventMgt\Service\BeUserSessionService;
23
use DERHANSEN\SfEventMgt\Service\ExportService;
24
use DERHANSEN\SfEventMgt\Service\MaintenanceService;
25
use DERHANSEN\SfEventMgt\Service\SettingsService;
26
use Psr\Http\Message\ResponseInterface;
27
use TYPO3\CMS\Backend\Routing\UriBuilder;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Routing\UriBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Template\Components\ButtonBar was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
use TYPO3\CMS\Backend\Template\ModuleTemplate;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Template\ModuleTemplate was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Template\ModuleTemplateFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
31
use TYPO3\CMS\Backend\Utility\BackendUtility;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Utility\BackendUtility was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
33
use TYPO3\CMS\Core\Imaging\Icon;
34
use TYPO3\CMS\Core\Imaging\IconFactory;
35
use TYPO3\CMS\Core\Localization\LanguageService;
36
use TYPO3\CMS\Core\Page\PageRenderer;
37
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
38
use TYPO3\CMS\Core\Utility\GeneralUtility;
39
40
class AdministrationController extends AbstractController
41
{
42
    private const LANG_FILE = 'LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:';
43
44
    protected ModuleTemplateFactory $moduleTemplateFactory;
45
    protected CustomNotificationLogRepository $customNotificationLogRepository;
46
    protected ExportService $exportService;
47
    protected SettingsService $settingsService;
48
    protected BeUserSessionService $beUserSessionService;
49
    protected MaintenanceService $maintenanceService;
50
    protected IconFactory $iconFactory;
51
    protected PageRenderer $pageRenderer;
52
    protected int $pid = 0;
53
54
    public function injectCustomNotificationLogRepository(
55
        CustomNotificationLogRepository $customNotificationLogRepository
56
    ): void {
57
        $this->customNotificationLogRepository = $customNotificationLogRepository;
58
    }
59
60
    public function injectExportService(ExportService $exportService): void
61
    {
62
        $this->exportService = $exportService;
63
    }
64
65
    public function injectSettingsService(SettingsService $settingsService): void
66
    {
67
        $this->settingsService = $settingsService;
68
    }
69
70
    public function injectBeUserSessionService(BeUserSessionService $beUserSessionService): void
71
    {
72
        $this->beUserSessionService = $beUserSessionService;
73
    }
74
75
    public function injectIconFactory(IconFactory $iconFactory): void
76
    {
77
        $this->iconFactory = $iconFactory;
78
    }
79
80
    public function injectMaintenanceService(MaintenanceService $maintenanceService): void
81
    {
82
        $this->maintenanceService = $maintenanceService;
83
    }
84
85
    public function injectModuleTemplateFactory(ModuleTemplateFactory $moduleTemplateFactory): void
86
    {
87
        $this->moduleTemplateFactory = $moduleTemplateFactory;
88
    }
89
90
    public function injectPageRenderer(PageRenderer $pageRenderer): void
91
    {
92
        $this->pageRenderer = $pageRenderer;
93
    }
94
95
    /**
96
     * Register docHeaderButtons
97
     */
98
    protected function registerDocHeaderButtons(ModuleTemplate $moduleTemplate): void
99
    {
100
        $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
101
102
        if ($this->request->getControllerActionName() === 'list') {
103
            $buttons = [
104
                [
105
                    'label' => 'administration.newEvent',
106
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_event'),
107
                    'icon' => 'ext-sfeventmgt-event',
108
                    'group' => 1,
109
                ],
110
                [
111
                    'label' => 'administration.newLocation',
112
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_location'),
113
                    'icon' => 'ext-sfeventmgt-location',
114
                    'group' => 1,
115
                ],
116
                [
117
                    'label' => 'administration.newOrganisator',
118
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_organisator'),
119
                    'icon' => 'ext-sfeventmgt-organisator',
120
                    'group' => 1,
121
                ],
122
                [
123
                    'label' => 'administration.newSpeaker',
124
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_speaker'),
125
                    'icon' => 'ext-sfeventmgt-speaker',
126
                    'group' => 1,
127
                ],
128
                [
129
                    'label' => 'administration.handleExpiredRegistrations',
130
                    'link' => $this->uriBuilder->reset()->setRequest($this->request)
131
                        ->uriFor('handleExpiredRegistrations', [], 'Administration'),
132
                    'icon' => 'ext-sfeventmgt-action-handle-expired',
133
                    'group' => 2,
134
                ],
135
            ];
136
            foreach ($buttons as $tableConfiguration) {
137
                $title = $this->getLanguageService()->sL(self::LANG_FILE . $tableConfiguration['label']);
138
                $icon = $this->iconFactory->getIcon($tableConfiguration['icon'], Icon::SIZE_SMALL);
139
                $viewButton = $buttonBar->makeLinkButton()
140
                    ->setHref($tableConfiguration['link'])
141
                    ->setDataAttributes([
142
                        'toggle' => 'tooltip',
143
                        'placement' => 'bottom',
144
                        'title' => $title,
145
                    ])
146
                    ->setTitle($title)
147
                    ->setIcon($icon);
148
                $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, $tableConfiguration['group']);
149
            }
150
        }
151
    }
152
153
    /**
154
     * Returns the create new record URL for the given table
155
     */
156
    private function getCreateNewRecordUri(string $table): string
157
    {
158
        $pid = $this->pid;
159
        $tsConfig = BackendUtility::getPagesTSconfig(0);
160
        if ($pid === 0 && isset($tsConfig['defaultPid.'])
161
            && is_array($tsConfig['defaultPid.'])
162
            && isset($tsConfig['defaultPid.'][$table])
163
        ) {
164
            $pid = (int)$tsConfig['defaultPid.'][$table];
165
        }
166
167
        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
168
169
        return (string)$uriBuilder->buildUriFromRoute('record_edit', [
170
            'edit[' . $table . '][' . $pid . ']' => 'new',
171
            'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
172
        ]);
173
    }
174
175
    /**
176
     * Initializes module template and returns a response which must be used as response for any extbase action
177
     * that should render a view.
178
     */
179
    protected function initModuleTemplateAndReturnResponse(string $templateFileName, array $variables = []): ResponseInterface
180
    {
181
        $moduleTemplate = $this->moduleTemplateFactory->create($this->request);
182
        $this->pageRenderer->addCssFile('EXT:sf_event_mgt/Resources/Public/Css/administration.css');
183
184
        $this->pageRenderer->loadJavaScriptModule('@derhansen/sf_event_mgt/administration-module.js');
185
186
        $this->registerDocHeaderButtons($moduleTemplate);
187
188
        $moduleTemplate->setFlashMessageQueue($this->getFlashMessageQueue());
189
190
        $initAdministrationModuleTemplateEvent = new InitAdministrationModuleTemplateEvent(
191
            $moduleTemplate,
192
            $this->uriBuilder,
193
            $this
194
        );
195
        $this->eventDispatcher->dispatch($initAdministrationModuleTemplateEvent);
196
197
        $variables['settings'] = $this->settings;
198
        $moduleTemplate->assignMultiple($variables);
199
200
        return $moduleTemplate->renderResponse($templateFileName);
201
    }
202
203
    public function initializeAction(): void
204
    {
205
        $this->pid = (int)($this->request->getQueryParams()['id'] ?? 0);
206
    }
207
208
    /**
209
     * Set date format for fields startDate and endDate
210
     */
211
    public function initializeListAction(): void
212
    {
213
        // Static format needed for date picker (flatpickr), see BackendController::generateJavascript() and #91606
214
        if (!empty($this->settings)) {
215
            $this->settings['search']['dateFormat'] = 'H:i d-m-Y';
0 ignored issues
show
Bug Best Practice introduced by
The property settings does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
216
        }
217
    }
218
219
    /**
220
     * List action for backend module
221
     */
222
    public function listAction(?SearchDemand $searchDemand = null, array $overwriteDemand = []): ResponseInterface
223
    {
224
        if (empty($this->settings)) {
225
            return $this->redirect('settingsError');
226
        }
227
228
        if ($searchDemand !== null) {
229
            $searchDemand->setFields($this->settings['search']['fields'] ?? 'title');
230
231
            $sessionData = [];
232
            $sessionData['searchDemand'] = $searchDemand->toArray();
233
            $sessionData['overwriteDemand'] = $overwriteDemand;
234
            $this->beUserSessionService->saveSessionData($sessionData);
235
        } else {
236
            // Try to restore search demand from Session
237
            $sessionSearchDemand = $this->beUserSessionService->getSessionDataByKey('searchDemand') ?? [];
238
            $searchDemand = SearchDemand::fromArray($sessionSearchDemand);
239
            $overwriteDemand = $this->beUserSessionService->getSessionDataByKey('overwriteDemand');
240
        }
241
242
        if ($this->isResetFilter()) {
243
            $searchDemand = GeneralUtility::makeInstance(SearchDemand::class);
244
            $overwriteDemand = [];
245
246
            $sessionData = [];
247
            $sessionData['searchDemand'] = $searchDemand->toArray();
248
            $sessionData['overwriteDemand'] = $overwriteDemand;
249
            $this->beUserSessionService->saveSessionData($sessionData);
250
        }
251
252
        // Initialize default ordering when no overwriteDemand is available
253
        if (empty($overwriteDemand)) {
254
            $overwriteDemand = [
255
                'orderField' => $this->settings['defaultSorting']['orderField'] ?? 'title',
256
                'orderDirection' => $this->settings['defaultSorting']['orderDirection'] ?? 'asc',
257
            ];
258
        }
259
260
        $eventDemand = GeneralUtility::makeInstance(EventDemand::class);
261
        $eventDemand = $this->overwriteEventDemandObject($eventDemand, $overwriteDemand);
0 ignored issues
show
Bug introduced by
It seems like $overwriteDemand can also be of type null; however, parameter $overwriteDemand of DERHANSEN\SfEventMgt\Con...riteEventDemandObject() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

261
        $eventDemand = $this->overwriteEventDemandObject($eventDemand, /** @scrutinizer ignore-type */ $overwriteDemand);
Loading history...
262
        $eventDemand->setOrderFieldAllowed($this->settings['orderFieldAllowed'] ?? '');
263
        $eventDemand->setSearchDemand($searchDemand);
264
        $eventDemand->setStoragePage((string)$this->pid);
265
        $eventDemand->setIgnoreEnableFields(true);
266
267
        $events = [];
268
        $pagination = null;
269
        if ($this->getBackendUser()->isInWebMount($this->pid) &&
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->getBackendUser()->isInWebMount($this->pid) of type integer|null is loosely compared to true; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
270
            $this->getBackendUser()->check('tables_select', 'tx_sfeventmgt_domain_model_event')
271
        ) {
272
            $events = $this->eventRepository->findDemanded($eventDemand);
273
            $pagination = $this->getPagination($events, $this->settings['pagination'] ?? []);
274
        }
275
276
        $modifyAdministrationListViewVariablesEvent = new ModifyAdministrationListViewVariablesEvent(
277
            [
278
                'pid' => $this->pid,
279
                'events' => $events,
280
                'searchDemand' => $searchDemand,
281
                'orderByFields' => $this->getOrderByFields(),
282
                'orderDirections' => $this->getOrderDirections(),
283
                'overwriteDemand' => $overwriteDemand,
284
                'pagination' => $pagination,
285
            ],
286
            $this
287
        );
288
        $this->eventDispatcher->dispatch($modifyAdministrationListViewVariablesEvent);
289
        $variables = $modifyAdministrationListViewVariablesEvent->getVariables();
290
291
        return $this->initModuleTemplateAndReturnResponse('Administration/List', $variables);
292
    }
293
294
    /**
295
     * Returns, if reset filter operation has been used
296
     */
297
    private function isResetFilter(): bool
298
    {
299
        $resetFilter = false;
300
        if ($this->request->hasArgument('operation')) {
301
            $resetFilter = $this->request->getArgument('operation') === 'reset-filters';
302
        }
303
304
        return $resetFilter;
305
    }
306
307
    /**
308
     * Export registrations for a given event
309
     */
310
    public function exportAction(int $eventUid): void
311
    {
312
        /** @var Event $event */
313
        $event = $this->eventRepository->findByUidIncludeHidden($eventUid);
314
        if ($event !== null && $this->checkEventAccess($event)) {
315
            $this->exportService->downloadRegistrationsCsv($eventUid, $this->settings['csvExport'] ?? []);
316
        }
317
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
318
    }
319
320
    /**
321
     * Handles expired registrations
322
     */
323
    public function handleExpiredRegistrationsAction(): ResponseInterface
324
    {
325
        $delete = (bool)($this->settings['registration']['deleteExpiredRegistrations'] ?? false);
326
        $this->maintenanceService->handleExpiredRegistrations($delete);
327
328
        $this->addFlashMessage(
329
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-1.content'),
330
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-1.title')
331
        );
332
333
        return $this->redirect('list');
334
    }
335
336
    /**
337
     * The index notify action
338
     */
339
    public function indexNotifyAction(Event $event): ResponseInterface
340
    {
341
        if (!$this->checkEventAccess($event)) {
342
            return $this->redirect('list');
343
        }
344
345
        $customNotification = GeneralUtility::makeInstance(CustomNotification::class);
346
        $customNotifications = $this->settingsService->getCustomNotifications($this->settings);
347
        $logEntries = $this->customNotificationLogRepository->findByEvent($event);
348
349
        $modifyAdministrationIndexNotifyViewVariablesEvent = new ModifyAdministrationIndexNotifyViewVariablesEvent(
350
            [
351
                'event' => $event,
352
                'recipients' => $this->getNotificationRecipients(),
353
                'customNotification' => $customNotification,
354
                'customNotifications' => $customNotifications,
355
                'logEntries' => $logEntries,
356
            ],
357
            $this
358
        );
359
        $this->eventDispatcher->dispatch($modifyAdministrationIndexNotifyViewVariablesEvent);
360
        $variables = $modifyAdministrationIndexNotifyViewVariablesEvent->getVariables();
361
362
        return $this->initModuleTemplateAndReturnResponse('Administration/IndexNotify', $variables);
363
    }
364
365
    /**
366
     * Returns an array of recipient option for the indexNotify action
367
     */
368
    public function getNotificationRecipients(): array
369
    {
370
        return [
371
            [
372
                'value' => CustomNotification::RECIPIENTS_ALL,
373
                'label' => $this->getLanguageService()->sL(
374
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_ALL
375
                ),
376
            ],
377
            [
378
                'value' => CustomNotification::RECIPIENTS_CONFIRMED,
379
                'label' => $this->getLanguageService()->sL(
380
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_CONFIRMED
381
                ),
382
            ],
383
            [
384
                'value' => CustomNotification::RECIPIENTS_UNCONFIRMED,
385
                'label' => $this->getLanguageService()->sL(
386
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_UNCONFIRMED
387
                ),
388
            ],
389
            [
390
                'value' => CustomNotification::RECIPIENTS_WAITLIST_CONFIRMED,
391
                'label' => $this->getLanguageService()->sL(
392
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_WAITLIST_CONFIRMED
393
                ),
394
            ],
395
            [
396
                'value' => CustomNotification::RECIPIENTS_WAITLIST_UNCONFIRMED,
397
                'label' => $this->getLanguageService()->sL(
398
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_WAITLIST_UNCONFIRMED
399
                ),
400
            ],
401
        ];
402
    }
403
404
    /**
405
     * Notify action
406
     */
407
    public function notifyAction(Event $event, CustomNotification $customNotification): ResponseInterface
408
    {
409
        if (!$this->checkEventAccess($event)) {
410
            return $this->redirect('list');
411
        }
412
413
        $customNotifications = $this->settingsService->getCustomNotifications($this->settings);
414
        $result = $this->notificationService->sendCustomNotification($event, $customNotification, $this->settings);
415
        $this->notificationService->createCustomNotificationLogentry(
416
            $event,
417
            $customNotifications[$customNotification->getTemplate()],
418
            $result,
419
            $customNotification
420
        );
421
        $this->addFlashMessage(
422
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-2.content'),
423
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-2.title')
424
        );
425
        return $this->redirect('list');
426
    }
427
428
    /**
429
     * Checks if the current backend user has access to the PID of the event and if not, enqueue an
430
     * access denied flash message
431
     */
432
    public function checkEventAccess(Event $event): bool
433
    {
434
        if ($this->getBackendUser()->isInWebMount($event->getPid()) === null) {
435
            $this->addFlashMessage(
436
                $this->getLanguageService()->sL(self::LANG_FILE . 'administration.accessdenied.content'),
437
                $this->getLanguageService()->sL(self::LANG_FILE . 'administration.accessdenied.title'),
438
                ContextualFeedbackSeverity::ERROR
439
            );
440
            return false;
441
        }
442
443
        return true;
444
    }
445
446
    /**
447
     * Shows the settings error view
448
     */
449
    public function settingsErrorAction(): ResponseInterface
450
    {
451
        return $this->initModuleTemplateAndReturnResponse('Administration/SettingsError');
452
    }
453
454
    /**
455
     * Suppress default validation messages
456
     */
457
    protected function getErrorFlashMessage(): bool
458
    {
459
        return false;
460
    }
461
462
    /**
463
     * Returns an array with possible order directions
464
     */
465
    public function getOrderDirections(): array
466
    {
467
        return [
468
            'asc' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.sortOrder.asc'),
469
            'desc' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.sortOrder.desc'),
470
        ];
471
    }
472
473
    /**
474
     * Returns an array with possible orderBy fields
475
     */
476
    public function getOrderByFields(): array
477
    {
478
        return [
479
            'title' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.title'),
480
            'startdate' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.startdate'),
481
            'enddate' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.enddate'),
482
        ];
483
    }
484
485
    protected function getLanguageService(): LanguageService
486
    {
487
        return $GLOBALS['LANG'];
488
    }
489
490
    protected function getBackendUser(): BackendUserAuthentication
491
    {
492
        return $GLOBALS['BE_USER'];
493
    }
494
}
495