Completed
Push — master ( 24268e...17edcb )
by Torben
01:14
created

AdministrationController   A

Complexity

Total Complexity 41

Size/Duplication

Total Lines 506
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 26

Test Coverage

Coverage 97.01%

Importance

Changes 0
Metric Value
wmc 41
lcom 1
cbo 26
dl 0
loc 506
ccs 65
cts 67
cp 0.9701
rs 9.1199
c 0
b 0
f 0

24 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeListAction() 0 20 3
B initializeView() 0 26 6
A injectCustomNotificationLogRepository() 0 5 1
A injectExportService() 0 4 1
A injectSettingsService() 0 4 1
A injectBeUserSessionService() 0 4 1
A injectIconFactory() 0 4 1
A injectMaintenanceService() 0 4 1
B registerDocHeaderButtons() 0 57 3
A getCreateNewRecordUri() 0 18 5
A initializeAction() 0 4 1
A listAction() 0 37 3
A exportAction() 0 10 2
A handleExpiredRegistrationsAction() 0 13 1
A indexNotifyAction() 0 14 1
A getNotificationRecipients() 0 23 1
A notifyAction() 0 17 1
A checkEventAccess() 0 12 2
A settingsErrorAction() 0 3 1
A getErrorFlashMessage() 0 4 1
A getLanguageService() 0 4 1
A getOrderDirections() 0 7 1
A getOrderByFields() 0 8 1
A getBackendUser() 0 4 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

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
/*
4
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
5
 *
6
 * For the full copyright and license information, please read the
7
 * LICENSE.txt file that was distributed with this source code.
8
 */
9
10
namespace DERHANSEN\SfEventMgt\Controller;
11
12
use DERHANSEN\SfEventMgt\Domain\Model\Dto\CustomNotification;
13
use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand;
14
use DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand;
15
use DERHANSEN\SfEventMgt\Domain\Model\Event;
16
use DERHANSEN\SfEventMgt\Service;
17
use TYPO3\CMS\Backend\Routing\UriBuilder;
18
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
19
use TYPO3\CMS\Backend\Utility\BackendUtility;
20
use TYPO3\CMS\Backend\View\BackendTemplateView;
21
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
22
use TYPO3\CMS\Core\Imaging\Icon;
23
use TYPO3\CMS\Core\Imaging\IconFactory;
24
use TYPO3\CMS\Core\Localization\LanguageService;
25
use TYPO3\CMS\Core\Messaging\FlashMessage;
26
use TYPO3\CMS\Core\Utility\GeneralUtility;
27
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
28
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder as ExtbaseUriBuilder;
29
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter;
30
31
/**
32
 * AdministrationController
33
 *
34
 * Several parts are heavily inspired by ext:news from Georg Ringer
35
 *
36
 * @author Torben Hansen <[email protected]>
37
 */
38
class AdministrationController extends AbstractController
39
{
40
    const LANG_FILE = 'LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:';
41
42
    /**
43
     * Backend Template Container
44
     *
45
     * @var string
46
     */
47
    protected $defaultViewObjectName = \TYPO3\CMS\Backend\View\BackendTemplateView::class;
48
49
    /**
50
     * CustomNotificationLogRepository
51
     *
52
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository
53
     */
54
    protected $customNotificationLogRepository;
55
56
    /**
57
     * ExportService
58
     *
59
     * @var \DERHANSEN\SfEventMgt\Service\ExportService
60
     */
61
    protected $exportService;
62
63
    /**
64
     * SettingsService
65
     *
66
     * @var \DERHANSEN\SfEventMgt\Service\SettingsService
67
     */
68
    protected $settingsService;
69
70
    /**
71
     * Backend User Session Service
72
     *
73
     * @var \DERHANSEN\SfEventMgt\Service\BeUserSessionService
74
     */
75
    protected $beUserSessionService;
76
77
    /**
78
     * @var \DERHANSEN\SfEventMgt\Service\MaintenanceService
79
     */
80
    protected $maintenanceService;
81
82
    /**
83
     * The current page uid
84
     *
85
     * @var int
86
     */
87
    protected $pid = 0;
88
89
    /**
90
     * BackendTemplateContainer
91 2
     *
92
     * @var BackendTemplateView
93 2
     */
94 2
    protected $view;
95
96
    /**
97
     * @var IconFactory
98
     */
99
    protected $iconFactory;
100
101 4
    /**
102
     * DI for $customNotificationLogRepository
103 4
     *
104 2
     * @param \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository
105 2
     */
106 4
    public function injectCustomNotificationLogRepository(
107 4
        \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository
108 4
    ) {
109 4
        $this->customNotificationLogRepository = $customNotificationLogRepository;
110 4
    }
111 4
112 4
    /**
113 4
     * DI for $exportService
114 4
     *
115 4
     * @param Service\ExportService $exportService
116 4
     */
117 4
    public function injectExportService(\DERHANSEN\SfEventMgt\Service\ExportService $exportService)
118 4
    {
119 4
        $this->exportService = $exportService;
120 4
    }
121
122
    /**
123
     * DI for $settingsService
124
     *
125
     * @param Service\SettingsService $settingsService
126
     */
127
    public function injectSettingsService(\DERHANSEN\SfEventMgt\Service\SettingsService $settingsService)
128
    {
129
        $this->settingsService = $settingsService;
130 8
    }
131
132
    /**
133 8
     * DI for $beUserSessionService
134
     *
135 8
     * @param Service\BeUserSessionService $beUserSessionService
136 6
     */
137 6
    public function injectBeUserSessionService(\DERHANSEN\SfEventMgt\Service\BeUserSessionService $beUserSessionService)
138 8
    {
139
        $this->beUserSessionService = $beUserSessionService;
140 8
    }
141 4
142 4
    /**
143
     * DI for $iconFactory
144 8
     *
145 2
     * @param IconFactory $iconFactory
146 2
     */
147 2
    public function injectIconFactory(IconFactory $iconFactory)
148 2
    {
149
        $this->iconFactory = $iconFactory;
150 8
    }
151 8
152 8
    /**
153 8
     * @param Service\MaintenanceService $maintenanceService
154
     */
155
    public function injectMaintenanceService(\DERHANSEN\SfEventMgt\Service\MaintenanceService $maintenanceService)
156
    {
157
        $this->maintenanceService = $maintenanceService;
158
    }
159
160
    /**
161
     * Set up the doc header properly here
162 2
     *
163
     * @param ViewInterface $view
164 2
     */
165 2
    protected function initializeView(ViewInterface $view)
166
    {
167
        /** @var BackendTemplateView $view */
168
        parent::initializeView($view);
169
        if ($this->actionMethodName === 'listAction'
170
            || $this->actionMethodName === 'indexNotifyAction'
171
            || $this->actionMethodName === 'settingsErrorAction'
172
        ) {
173 2
            $this->registerDocHeaderButtons();
174
175 2
            $pageRenderer = $this->view->getModuleTemplate()->getPageRenderer();
176 2
            $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DateTimePicker');
177 2
178
            $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ?
179
                ['MM-DD-YYYY', 'HH:mm MM-DD-YYYY'] :
180
                ['DD-MM-YYYY', 'HH:mm DD-MM-YYYY'];
181
            $pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat);
182
183
            $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
184
            if ($view instanceof BackendTemplateView) {
185
                $view->getModuleTemplate()->getPageRenderer()->addCssFile(
186 2
                    'EXT:sf_event_mgt/Resources/Public/Css/administration.css'
187
                );
188 2
            }
189 2
        }
190 2
    }
191 2
192 2
    /**
193 2
     * Register docHeaderButtons
194 2
     */
195 2
    protected function registerDocHeaderButtons()
196
    {
197
        $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
198
199
        $uriBuilder = $this->objectManager->get(ExtbaseUriBuilder::class);
0 ignored issues
show
Deprecated Code introduced by
The method TYPO3\CMS\Extbase\Object...ManagerInterface::get() has been deprecated with message: since TYPO3 10.4, will be removed in version 12.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
200
        $uriBuilder->setRequest($this->request);
201
202
        if ($this->request->getControllerActionName() === 'list') {
203
            $buttons = [
204
                [
205 2
                    'label' => 'administration.newEvent',
206
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_event'),
207 2
                    'icon' => 'ext-sfeventmgt-event',
208 2
                    'group' => 1
209 2
                ],
210 2
                [
211 2
                    'label' => 'administration.newLocation',
212
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_location'),
213 2
                    'icon' => 'ext-sfeventmgt-location',
214 2
                    'group' => 1
215 2
                ],
216
                [
217
                    'label' => 'administration.newOrganisator',
218
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_organisator'),
219
                    'icon' => 'ext-sfeventmgt-organisator',
220
                    'group' => 1
221
                ],
222
                [
223
                    'label' => 'administration.newSpeaker',
224
                    'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_speaker'),
225
                    'icon' => 'ext-sfeventmgt-speaker',
226
                    'group' => 1
227
                ],
228
                [
229
                    'label' => 'administration.handleExpiredRegistrations',
230
                    'link' => $uriBuilder->reset()->setRequest($this->request)
231
                        ->uriFor('handleExpiredRegistrations', [], 'Administration'),
232
                    'icon' => 'ext-sfeventmgt-action-handle-expired',
233
                    'group' => 2,
234
                ]
235
            ];
236
            foreach ($buttons as $key => $tableConfiguration) {
237
                $title = $this->getLanguageService()->sL(self::LANG_FILE . $tableConfiguration['label']);
238
                $icon = $this->iconFactory->getIcon($tableConfiguration['icon'], Icon::SIZE_SMALL);
239
                $viewButton = $buttonBar->makeLinkButton()
240
                    ->setHref($tableConfiguration['link'])
241
                    ->setDataAttributes([
242
                        'toggle' => 'tooltip',
243
                        'placement' => 'bottom',
244
                        'title' => $title
245
                        ])
246
                    ->setTitle($title)
247
                    ->setIcon($icon);
248
                $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, $tableConfiguration['group']);
249
            }
250
        }
251
    }
252
253
    /**
254
     * Returns the create new record URL for the given table
255
     *
256
     * @param $table
257
     * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
258
     * @return string
259
     */
260
    private function getCreateNewRecordUri($table): string
261
    {
262
        $pid = $this->pid;
263
        $tsConfig = BackendUtility::getPagesTSconfig(0);
264
        if ($pid === 0 && isset($tsConfig['defaultPid.'])
265
            && is_array($tsConfig['defaultPid.'])
266
            && isset($tsConfig['defaultPid.'][$table])
267
        ) {
268
            $pid = (int)$tsConfig['defaultPid.'][$table];
269
        }
270
271
        $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
272
273
        return $uriBuilder->buildUriFromRoute('record_edit', [
274
            'edit[' . $table . '][' . $pid . ']' => 'new',
275
            'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
276
        ]);
277
    }
278
279
    /**
280
     * Initialize action
281
     */
282
    public function initializeAction()
283
    {
284
        $this->pid = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id');
285
    }
286
287
    /**
288
     * Set date format for fields startDate and endDate
289
     */
290
    public function initializeListAction()
291
    {
292
        if ($this->settings === null || empty($this->settings)) {
293
            $this->redirect('settingsError');
294
        }
295
        $this->arguments->getArgument('searchDemand')
296
            ->getPropertyMappingConfiguration()->forProperty('startDate')
297
            ->setTypeConverterOption(
298
                DateTimeConverter::class,
299
                DateTimeConverter::CONFIGURATION_DATE_FORMAT,
300
                $this->settings['search']['dateFormat']
301
            );
302
        $this->arguments->getArgument('searchDemand')
303
            ->getPropertyMappingConfiguration()->forProperty('endDate')
304
            ->setTypeConverterOption(
305
                DateTimeConverter::class,
306
                DateTimeConverter::CONFIGURATION_DATE_FORMAT,
307
                $this->settings['search']['dateFormat']
308
            );
309
    }
310
311
    /**
312
     * List action for backend module
313
     *
314
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand $searchDemand SearchDemand
315
     * @param array $overwriteDemand OverwriteDemand
316
     */
317
    public function listAction(SearchDemand $searchDemand = null, array $overwriteDemand = [])
318
    {
319
        /** @var EventDemand $eventDemand */
320
        $eventDemand = $this->objectManager->get(EventDemand::class);
0 ignored issues
show
Deprecated Code introduced by
The method TYPO3\CMS\Extbase\Object...ManagerInterface::get() has been deprecated with message: since TYPO3 10.4, will be removed in version 12.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
321
        $eventDemand = $this->overwriteEventDemandObject($eventDemand, $overwriteDemand);
322
        $eventDemand->setOrderFieldAllowed($this->settings['orderFieldAllowed']);
323
324
        if ($searchDemand !== null) {
325
            $searchDemand->setFields($this->settings['search']['fields']);
326
327
            $sessionData = [];
328
            $sessionData['searchDemand'] = $searchDemand;
329
            $sessionData['overwriteDemand'] = $overwriteDemand;
330
            $this->beUserSessionService->saveSessionData($sessionData);
331
        } else {
332
            // Try to restore search demand from Session
333
            $searchDemand = $this->beUserSessionService->getSessionDataByKey('searchDemand');
334
            $overwriteDemand = $this->beUserSessionService->getSessionDataByKey('overwriteDemand');
335
        }
336
337
        $eventDemand->setSearchDemand($searchDemand);
338
        $eventDemand->setStoragePage($this->pid);
339
340
        $events = [];
341
        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 zero. 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...
342
            $events = $this->eventRepository->findDemanded($eventDemand);
343
        }
344
345
        $this->view->assignMultiple([
346
            'pid' => $this->pid,
347
            'events' => $events,
348
            'searchDemand' => $searchDemand,
349
            'orderByFields' => $this->getOrderByFields(),
350
            'orderDirections' => $this->getOrderDirections(),
351
            'overwriteDemand' => $overwriteDemand,
352
        ]);
353
    }
354
355
    /**
356
     * Export registrations for a given event
357
     *
358
     * @param int $eventUid Event UID
359
     */
360
    public function exportAction($eventUid)
361
    {
362
        /** @var Event $event */
363
        $event = $this->eventRepository->findByUid($eventUid);
364
        if ($event) {
365
            $this->checkEventAccess($event);
366
            $this->exportService->downloadRegistrationsCsv($eventUid, $this->settings['csvExport']);
367
        }
368
        exit();
369
    }
370
371
    /**
372
     * Handles expired registrations
373
     */
374
    public function handleExpiredRegistrationsAction()
375
    {
376
        $delete = (bool)$this->settings['registration']['deleteExpiredRegistrations'];
377
        $this->maintenanceService->handleExpiredRegistrations($delete);
378
379
        $this->addFlashMessage(
380
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-1.content'),
381
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-1.title'),
382
            FlashMessage::OK
383
        );
384
385
        $this->redirect('list');
386
    }
387
388
    /**
389
     * The index notify action
390
     *
391
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
392
     */
393
    public function indexNotifyAction(Event $event)
394
    {
395
        $this->checkEventAccess($event);
396
        $customNotification = GeneralUtility::makeInstance(CustomNotification::class);
397
        $customNotifications = $this->settingsService->getCustomNotifications($this->settings);
398
        $logEntries = $this->customNotificationLogRepository->findByEvent($event);
0 ignored issues
show
Documentation Bug introduced by
The method findByEvent does not exist on object<DERHANSEN\SfEvent...ificationLogRepository>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
399
        $this->view->assignMultiple([
400
            'event' => $event,
401
            'recipients' => $this->getNotificationRecipients(),
402
            'customNotification' => $customNotification,
403
            'customNotifications' => $customNotifications,
404
            'logEntries' => $logEntries,
405
        ]);
406
    }
407
408
    /**
409
     * Returns an array of recipient option for the indexNotify action
410
     *
411
     * @return array|array[]
412
     */
413
    public function getNotificationRecipients(): array
414
    {
415
        return [
416
            [
417
                'value' => CustomNotification::RECIPIENTS_ALL,
418
                'label' => $this->getLanguageService()->sL(
419
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_ALL
420
                )
421
            ],
422
            [
423
                'value' => CustomNotification::RECIPIENTS_CONFIRMED,
424
                'label' => $this->getLanguageService()->sL(
425
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_CONFIRMED
426
                )
427
            ],
428
            [
429
                'value' => CustomNotification::RECIPIENTS_UNCONFIRMED,
430
                'label' => $this->getLanguageService()->sL(
431
                    self::LANG_FILE . 'administration.notify.recipients.' . CustomNotification::RECIPIENTS_UNCONFIRMED
432
                )
433
            ],
434
        ];
435
    }
436
437
    /**
438
     * Notify action
439
     *
440
     * @param Event $event Event
441
     * @param CustomNotification $customNotification
442
     */
443
    public function notifyAction(Event $event, CustomNotification $customNotification)
444
    {
445
        $this->checkEventAccess($event);
446
        $customNotifications = $this->settingsService->getCustomNotifications($this->settings);
447
        $result = $this->notificationService->sendCustomNotification($event, $customNotification, $this->settings);
448
        $this->notificationService->createCustomNotificationLogentry(
449
            $event,
450
            $customNotifications[$customNotification->getTemplate()],
451
            $result
452
        );
453
        $this->addFlashMessage(
454
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-2.content'),
455
            $this->getLanguageService()->sL(self::LANG_FILE . 'administration.message-2.title'),
456
            FlashMessage::OK
457
        );
458
        $this->redirect('list');
459
    }
460
461
    /**
462
     * Checks if the current backend user has access to the PID of the event and if not, enqueue an
463
     * access denied flash message and redirect to list view
464
     *
465
     * @param Event $event
466
     * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
467
     */
468
    public function checkEventAccess(Event $event)
469
    {
470
        if ($this->getBackendUser()->isInWebMount($event->getPid()) === null) {
471
            $this->addFlashMessage(
472
                $this->getLanguageService()->sL(self::LANG_FILE . 'administration.accessdenied.content'),
473
                $this->getLanguageService()->sL(self::LANG_FILE . 'administration.accessdenied.title'),
474
                FlashMessage::ERROR
475
            );
476
477
            $this->redirect('list');
478
        }
479
    }
480
481
    /**
482
     * Shows the settings error view
483
     */
484
    public function settingsErrorAction()
485
    {
486
    }
487
488
    /**
489
     * Suppress default validation messages
490
     *
491
     * @return bool
492
     */
493
    protected function getErrorFlashMessage()
494
    {
495
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type of the parent method TYPO3\CMS\Extbase\Mvc\Co...r::getErrorFlashMessage of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
496
    }
497
498
    /**
499
     * Returns the LanguageService
500
     *
501
     * @return LanguageService
502
     */
503
    protected function getLanguageService(): LanguageService
504
    {
505
        return $GLOBALS['LANG'];
506
    }
507
508
    /**
509
     * Returns an array with possible order directions
510
     *
511
     * @return array
512
     */
513
    public function getOrderDirections()
514
    {
515
        return [
516
            'asc' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.sortOrder.asc'),
517
            'desc' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.sortOrder.desc')
518
        ];
519
    }
520
521
    /**
522
     * Returns an array with possible orderBy fields
523
     *
524
     * @return array
525
     */
526
    public function getOrderByFields()
527
    {
528
        return [
529
            'title' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.title'),
530
            'startdate' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.startdate'),
531
            'enddate' => $this->getLanguageService()->sL(self::LANG_FILE . 'administration.orderBy.enddate')
532
        ];
533
    }
534
535
    /**
536
     * Returns the Backend User
537
     * @return BackendUserAuthentication
538
     */
539
    protected function getBackendUser(): BackendUserAuthentication
540
    {
541
        return $GLOBALS['BE_USER'];
542
    }
543
}
544