Completed
Push — master ( 6a1272...5ee59d )
by Tim
13s
created

CalendarController   F

Complexity

Total Complexity 75

Size/Duplication

Total Lines 650
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 18

Importance

Changes 0
Metric Value
wmc 75
lcom 1
cbo 18
dl 0
loc 650
rs 2.35
c 0
b 0
f 0

18 Methods

Rating   Name   Duplication   Size   Complexity  
C initializeAction() 0 57 10
A latestAction() 0 29 3
A resultAction() 0 29 3
A listAction() 0 31 3
B shortcutAction() 0 30 6
A pastAction() 0 11 1
A yearAction() 0 9 1
A quarterAction() 0 11 1
A monthAction() 0 9 1
A weekAction() 0 31 3
A dayAction() 0 18 1
B detailAction() 0 26 6
A searchAction() 0 19 4
B singleAction() 0 39 6
D determineSearch() 0 81 18
A getAllowedActions() 0 10 3
A getCurrentConfigurations() 0 12 3
A slottedRedirect() 0 30 2

How to fix   Complexity   

Complex Class

Complex classes like CalendarController 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 CalendarController, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * Calendar.
5
 */
6
declare(strict_types=1);
7
8
namespace HDNET\Calendarize\Controller;
9
10
use HDNET\Calendarize\Domain\Model\Index;
11
use HDNET\Calendarize\Register;
12
use HDNET\Calendarize\Utility\DateTimeUtility;
13
use HDNET\Calendarize\Utility\EventUtility;
14
use HDNET\Calendarize\Utility\ExtensionConfigurationUtility;
15
use HDNET\Calendarize\Utility\TranslateUtility;
16
use TYPO3\CMS\Backend\Utility\BackendUtility;
17
use TYPO3\CMS\Core\Utility\ClassNamingUtility;
18
use TYPO3\CMS\Core\Utility\GeneralUtility;
19
use TYPO3\CMS\Core\Utility\MathUtility;
20
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
21
use TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface;
22
use TYPO3\CMS\Extbase\Object\ObjectManager;
23
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
24
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter;
25
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
26
27
/**
28
 * Calendar.
29
 */
30
class CalendarController extends AbstractController
31
{
32
    /**
33
     * Init all actions.
34
     */
35
    public function initializeAction()
36
    {
37
        parent::initializeAction();
38
        if (isset($this->settings['format'])) {
39
            $this->request->setFormat($this->settings['format']);
40
        }
41
        $this->indexRepository->setIndexTypes(GeneralUtility::trimExplode(',', $this->settings['configuration'], true));
42
        $additionalSlotArguments = [
43
            'contentRecord' => $this->configurationManager->getContentObject()->data,
44
            'settings' => $this->settings,
45
        ];
46
        $this->indexRepository->setAdditionalSlotArguments($additionalSlotArguments);
47
48
        if (isset($this->settings['sorting'])) {
49
            if (isset($this->settings['sortBy'])) {
50
                $this->indexRepository->setDefaultSortingDirection($this->settings['sorting'], $this->settings['sortBy']);
51
            } else {
52
                $this->indexRepository->setDefaultSortingDirection($this->settings['sorting']);
53
            }
54
        }
55
56
        if (isset($this->arguments['startDate'])) {
57
            $this->arguments['startDate']->getPropertyMappingConfiguration()
58
                ->setTypeConverterOption(
59
                    DateTimeConverter::class,
60
                    DateTimeConverter::CONFIGURATION_DATE_FORMAT,
61
                    $this->settings['dateFormat']
62
                );
63
        }
64
        if (isset($this->arguments['endDate'])) {
65
            $this->arguments['endDate']->getPropertyMappingConfiguration()
66
                ->setTypeConverterOption(
67
                    DateTimeConverter::class,
68
                    DateTimeConverter::CONFIGURATION_DATE_FORMAT,
69
                    $this->settings['dateFormat']
70
                );
71
        }
72
        if ($this->request->hasArgument('event') && 'detailAction' === $this->actionMethodName) {
73
            // default configuration
74
            $configurationName = $this->settings['configuration'];
75
            // configuration overwritten by argument?
76
            if ($this->request->hasArgument('extensionConfiguration')) {
77
                $configurationName = $this->request->getArgument('extensionConfiguration');
78
            }
79
            // get the configuration
80
            $configuration = ExtensionConfigurationUtility::get($configurationName);
81
82
            // get Event by Configuration and Uid
83
            $event = EventUtility::getOriginalRecordByConfiguration($configuration, (int) $this->request->getArgument('event'));
84
            $index = $this->indexRepository->findByEventTraversing($event, true, false, 1)->getFirst();
85
86
            // if there is a valid index in the event
87
            if ($index) {
88
                $this->redirect('detail', null, null, ['index' => $index]);
89
            }
90
        }
91
    }
92
93
    /**
94
     * Latest action.
95
     *
96
     * @param \HDNET\Calendarize\Domain\Model\Index $index
97
     * @param \DateTime                             $startDate
98
     * @param \DateTime                             $endDate
99
     * @param array                                 $customSearch *
100
     * @param int                                   $year
101
     * @param int                                   $month
102
     * @param int                                   $week
103
     *
104
     * @ignorevalidation $startDate
105
     * @ignorevalidation $endDate
106
     * @ignorevalidation $customSearch
107
     *
108
     * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
109
     */
110
    public function latestAction(
111
        Index $index = null,
112
        \DateTime $startDate = null,
113
        \DateTime $endDate = null,
114
        array $customSearch = [],
115
        $year = null,
116
        $month = null,
117
        $week = null
118
    ) {
119
        $this->checkStaticTemplateIsIncluded();
120
        if (($index instanceof Index) && \in_array('detail', $this->getAllowedActions(), true)) {
121
            $this->forward('detail');
122
        }
123
124
        $search = $this->determineSearch($startDate, $endDate, $customSearch, $year, $month, null, $week);
125
126
        $this->slotExtendedAssignMultiple([
127
            'indices' => $search['indices'],
128
            'searchMode' => $search['searchMode'],
129
            'searchParameter' => [
130
                'startDate' => $startDate,
131
                'endDate' => $endDate,
132
                'customSearch' => $customSearch,
133
                'year' => $year,
134
                'month' => $month,
135
                'week' => $week,
136
            ],
137
        ], __CLASS__, __FUNCTION__);
138
    }
139
140
    /**
141
     * Result action.
142
     *
143
     * @param \HDNET\Calendarize\Domain\Model\Index $index
144
     * @param \DateTime                             $startDate
145
     * @param \DateTime                             $endDate
146
     * @param array                                 $customSearch
147
     * @param int                                   $year
148
     * @param int                                   $month
149
     * @param int                                   $week
150
     *
151
     * @ignorevalidation $startDate
152
     * @ignorevalidation $endDate
153
     * @ignorevalidation $customSearch
154
     *
155
     * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
156
     */
157
    public function resultAction(
158
        Index $index = null,
159
        \DateTime $startDate = null,
160
        \DateTime $endDate = null,
161
        array $customSearch = [],
162
        $year = null,
163
        $month = null,
164
        $week = null
165
    ) {
166
        $this->checkStaticTemplateIsIncluded();
167
        if (($index instanceof Index) && \in_array('detail', $this->getAllowedActions(), true)) {
168
            $this->forward('detail');
169
        }
170
171
        $search = $this->determineSearch($startDate, $endDate, $customSearch, $year, $month, null, $week);
172
173
        $this->slotExtendedAssignMultiple([
174
            'indices' => $search['indices'],
175
            'searchMode' => $search['searchMode'],
176
            'searchParameter' => [
177
                'startDate' => $startDate,
178
                'endDate' => $endDate,
179
                'customSearch' => $customSearch,
180
                'year' => $year,
181
                'month' => $month,
182
                'week' => $week,
183
            ],
184
        ], __CLASS__, __FUNCTION__);
185
    }
186
187
    /**
188
     * List action.
189
     *
190
     * @param \HDNET\Calendarize\Domain\Model\Index $index
191
     * @param \DateTime                             $startDate
192
     * @param \DateTime                             $endDate
193
     * @param array                                 $customSearch *
194
     * @param int                                   $year
195
     * @param int                                   $month
196
     * @param int                                   $day
197
     * @param int                                   $week
198
     *
199
     * @ignorevalidation $startDate
200
     * @ignorevalidation $endDate
201
     * @ignorevalidation $customSearch
202
     *
203
     * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
204
     */
205
    public function listAction(
206
        Index $index = null,
207
        \DateTime $startDate = null,
208
        \DateTime $endDate = null,
209
        array $customSearch = [],
210
        $year = null,
211
        $month = null,
212
        $day = null,
213
        $week = null
214
    ) {
215
        $this->checkStaticTemplateIsIncluded();
216
        if (($index instanceof Index) && \in_array('detail', $this->getAllowedActions(), true)) {
217
            $this->forward('detail');
218
        }
219
220
        $search = $this->determineSearch($startDate, $endDate, $customSearch, $year, $month, $day, $week);
221
222
        $this->slotExtendedAssignMultiple([
223
            'indices' => $search['indices'],
224
            'searchMode' => $search['searchMode'],
225
            'searchParameter' => [
226
                'startDate' => $startDate,
227
                'endDate' => $endDate,
228
                'customSearch' => $customSearch,
229
                'year' => $year,
230
                'month' => $month,
231
                'day' => $day,
232
                'week' => $week,
233
            ],
234
        ], __CLASS__, __FUNCTION__);
235
    }
236
237
    /**
238
     * Shortcut.
239
     */
240
    public function shortcutAction()
241
    {
242
        list($table, $uid) = \explode(':', $GLOBALS['TSFE']->currentRecord);
243
        $register = Register::getRegister();
244
245
        $event = null;
246
        foreach ($register as $key => $value) {
247
            if ($value['tableName'] === $table) {
248
                $repositoryName = ClassNamingUtility::translateModelNameToRepositoryName($value['modelName']);
249
                if (\class_exists($repositoryName)) {
250
                    $objectManager = new ObjectManager();
251
                    $repository = $objectManager->get($repositoryName);
252
                    $event = $repository->findByUid($uid);
253
                }
254
            }
255
        }
256
257
        if (!($event instanceof DomainObjectInterface)) {
258
            return 'Invalid object';
259
        }
260
261
        $fetchEvent = $this->indexRepository->findByEventTraversing($event, true, false, 1);
262
        if (\count($fetchEvent) <= 0) {
263
            $fetchEvent = $this->indexRepository->findByEventTraversing($event, false, true, 1, QueryInterface::ORDER_DESCENDING);
264
        }
265
266
        $this->view->assignMultiple([
267
            'indices' => $fetchEvent,
268
        ]);
269
    }
270
271
    /**
272
     * Past action.
273
     *
274
     * @param int    $limit
275
     * @param string $sort
276
     *
277
     * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
278
     */
279
    public function pastAction(
280
        $limit = 100,
0 ignored issues
show
Unused Code introduced by
The parameter $limit is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
281
        $sort = 'ASC'
0 ignored issues
show
Unused Code introduced by
The parameter $sort is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
282
    ) {
283
        $limit = (int) ($this->settings['limit']);
284
        $sort = $this->settings['sorting'];
285
        $this->checkStaticTemplateIsIncluded();
286
        $this->slotExtendedAssignMultiple([
287
           'indices' => $this->indexRepository->findByPast($limit, $sort),
288
        ], __CLASS__, __FUNCTION__);
289
    }
290
291
    /**
292
     * Year action.
293
     *
294
     * @param int $year
295
     */
296
    public function yearAction($year = null)
297
    {
298
        $date = DateTimeUtility::normalizeDateTime(1, 1, $year);
299
300
        $this->slotExtendedAssignMultiple([
301
            'indices' => $this->indexRepository->findYear((int) $date->format('Y')),
302
            'date' => $date,
303
        ], __CLASS__, __FUNCTION__);
304
    }
305
306
    /**
307
     * Quarter action.
308
     *
309
     * @param int $year
310
     * @param int $quarter 1-4
311
     */
312
    public function quarterAction(int $year = null, int $quarter = null)
313
    {
314
        $quarter = DateTimeUtility::normalizeQuarter($quarter);
315
        $date = DateTimeUtility::normalizeDateTime(1, 1 + (($quarter - 1) * 3), $year);
316
317
        $this->slotExtendedAssignMultiple([
318
            'indices' => $this->indexRepository->findQuarter((int) $date->format('Y'), $quarter),
319
            'date' => $date,
320
            'quarter' => $quarter,
321
        ], __CLASS__, __FUNCTION__);
322
    }
323
324
    /**
325
     * Month action.
326
     *
327
     * @param int $year
328
     * @param int $month
329
     * @param int $day
330
     */
331
    public function monthAction($year = null, $month = null, $day = null)
332
    {
333
        $date = DateTimeUtility::normalizeDateTime($day, $month, $year);
334
335
        $this->slotExtendedAssignMultiple([
336
            'date' => $date,
337
            'indices' => $this->indexRepository->findMonth((int) $date->format('Y'), (int) $date->format('n')),
338
        ], __CLASS__, __FUNCTION__);
339
    }
340
341
    /**
342
     * Week action.
343
     *
344
     * @param int $year
345
     * @param int $week
346
     */
347
    public function weekAction($year = null, $week = null)
348
    {
349
        $now = DateTimeUtility::getNow();
350
        if (null === $year) {
351
            $year = $now->format('o'); // 'o' instead of 'Y': http://php.net/manual/en/function.date.php#106974
352
        }
353
        if (null === $week) {
354
            $week = $now->format('W');
355
        }
356
        $weekStart = (int) $this->settings['weekStart'];
357
        $firstDay = DateTimeUtility::convertWeekYear2DayMonthYear((int) $week, $year, $weekStart);
358
        $timezone = DateTimeUtility::getTimeZone();
359
        $firstDay->setTimezone($timezone);
360
        $firstDay->setTime(0, 0, 0);
361
362
        $weekConfiguration = [
363
            '+0 day' => 2,
364
            '+1 days' => 2,
365
            '+2 days' => 2,
366
            '+3 days' => 2,
367
            '+4 days' => 2,
368
            '+5 days' => 1,
369
            '+6 days' => 1,
370
        ];
371
372
        $this->slotExtendedAssignMultiple([
373
            'firstDay' => $firstDay,
374
            'indices' => $this->indexRepository->findWeek($year, $week, $this->settings['weekStart']),
375
            'weekConfiguration' => $weekConfiguration,
376
        ], __CLASS__, __FUNCTION__);
377
    }
378
379
    /**
380
     * Day action.
381
     *
382
     * @param int $year
383
     * @param int $month
384
     * @param int $day
385
     */
386
    public function dayAction($year = null, $month = null, $day = null)
387
    {
388
        $date = DateTimeUtility::normalizeDateTime($day, $month, $year);
389
        $date->modify('+12 hours');
390
391
        $previous = clone $date;
392
        $previous->modify('-1 day');
393
394
        $next = clone $date;
395
        $next->modify('+1 day');
396
397
        $this->slotExtendedAssignMultiple([
398
            'indices' => $this->indexRepository->findDay((int) $date->format('Y'), (int) $date->format('n'), (int) $date->format('j')),
399
            'today' => $date,
400
            'previous' => $previous,
401
            'next' => $next,
402
        ], __CLASS__, __FUNCTION__);
403
    }
404
405
    /**
406
     * Detail action.
407
     *
408
     * @param \HDNET\Calendarize\Domain\Model\Index $index
409
     *
410
     * @return string
411
     */
412
    public function detailAction(Index $index = null)
413
    {
414
        if (null === $index) {
415
            // handle fallback for "strange language settings"
416
            if ($this->request->hasArgument('index')) {
417
                $indexId = (int) $this->request->getArgument('index');
418
                if ($indexId > 0) {
419
                    $index = $this->indexRepository->findByUid($indexId);
420
                }
421
            }
422
423
            if (null === $index) {
424
                if (!MathUtility::canBeInterpretedAsInteger($this->settings['listPid'])) {
425
                    return (string) TranslateUtility::get('noEventDetailView');
426
                }
427
                $this->slottedRedirect(__CLASS__, __FUNCTION__ . 'noEvent');
428
            }
429
        }
430
431
        $this->slotExtendedAssignMultiple([
432
            'index' => $index,
433
            'domain' => GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'),
434
        ], __CLASS__, __FUNCTION__);
435
436
        return $this->view->render();
437
    }
438
439
    /**
440
     * Render the search view.
441
     *
442
     * @param \DateTime $startDate
443
     * @param \DateTime $endDate
444
     * @param array     $customSearch
445
     *
446
     * @ignorevalidation $startDate
447
     * @ignorevalidation $endDate
448
     * @ignorevalidation $customSearch
449
     */
450
    public function searchAction(\DateTime $startDate = null, \DateTime $endDate = null, array $customSearch = [])
451
    {
452
        $baseDate = DateTimeUtility::getNow();
453
        if (!($startDate instanceof \DateTimeInterface)) {
454
            $startDate = clone $baseDate;
455
        }
456
        if (!($endDate instanceof \DateTimeInterface)) {
457
            $endDate = clone $startDate;
458
            $modify = \is_string($this->settings['searchEndModifier']) ? $this->settings['searchEndModifier'] : '+30 days';
459
            $endDate->modify($modify);
460
        }
461
462
        $this->slotExtendedAssignMultiple([
463
            'startDate' => $startDate,
464
            'endDate' => $endDate,
465
            'customSearch' => $customSearch,
466
            'configurations' => $this->getCurrentConfigurations(),
467
        ], __CLASS__, __FUNCTION__);
468
    }
469
470
    /**
471
     * Render single items.
472
     */
473
    public function singleAction()
474
    {
475
        $indicies = [];
476
477
        // prepare selection
478
        $selections = [];
479
        $configurations = $this->getCurrentConfigurations();
480
        foreach (GeneralUtility::trimExplode(',', $this->settings['singleItems']) as $item) {
481
            list($table, $uid) = BackendUtility::splitTable_Uid($item);
482
            foreach ($configurations as $configuration) {
483
                if ($configuration['tableName'] === $table) {
484
                    $selections[] = [
485
                        'configuration' => $configuration,
486
                        'uid' => $uid,
487
                    ];
488
                    break;
489
                }
490
            }
491
        }
492
493
        // fetch index
494
        foreach ($selections as $selection) {
495
            $this->indexRepository->setIndexTypes([$selection['configuration']['uniqueRegisterKey']]);
496
            $dummyIndex = new Index();
497
            $dummyIndex->setForeignTable($selection['configuration']['tableName']);
498
            $dummyIndex->setForeignUid($selection['uid']);
499
500
            $result = $this->indexRepository->findByTraversing($dummyIndex);
501
            $index = $result->getQuery()->setLimit(1)->execute()->getFirst();
502
            if (\is_object($index)) {
503
                $indicies[] = $index;
504
            }
505
        }
506
507
        $this->slotExtendedAssignMultiple([
508
            'indicies' => $indicies,
509
            'configurations' => $configurations,
510
        ], __CLASS__, __FUNCTION__);
511
    }
512
513
    /**
514
     * Build the search structure.
515
     *
516
     * @param \DateTime|null $startDate
517
     * @param \DateTime|null $endDate
518
     * @param array          $customSearch
519
     * @param int            $year
520
     * @param int            $month
521
     * @param int            $day
522
     * @param int            $week
523
     *
524
     * @return array
525
     */
526
    protected function determineSearch(
527
        \DateTime $startDate = null,
528
        \DateTime $endDate = null,
529
        array $customSearch = [],
530
        $year = null,
531
        $month = null,
532
        $day = null,
533
        $week = null
534
    ) {
535
        $searchMode = false;
536
        if ($startDate || $endDate || !empty($customSearch)) {
537
            $searchMode = true;
538
            $limit = isset($this->settings['limit']) ? (int) $this->settings['limit'] : 0;
539
            $indices = $this->indexRepository->findBySearch($startDate, $endDate, $customSearch, $limit);
540
        } elseif (MathUtility::canBeInterpretedAsInteger($year) && MathUtility::canBeInterpretedAsInteger($month) && MathUtility::canBeInterpretedAsInteger($day)) {
541
            $indices = $this->indexRepository->findDay((int) $year, (int) $month, (int) $day);
542
        } elseif (MathUtility::canBeInterpretedAsInteger($year) && MathUtility::canBeInterpretedAsInteger($month)) {
543
            $indices = $this->indexRepository->findMonth((int) $year, (int) $month);
544
        } elseif (MathUtility::canBeInterpretedAsInteger($year) && MathUtility::canBeInterpretedAsInteger($week)) {
545
            $indices = $this->indexRepository->findWeek($year, $week, $this->settings['weekStart']);
546
        } elseif (MathUtility::canBeInterpretedAsInteger($year)) {
547
            $indices = $this->indexRepository->findYear((int) $year);
548
        } else {
549
            // check if relative dates are enabled
550
            if ((bool)$this->settings['useRelativeDate']) {
551
                $overrideStartDateRelative = trim($this->settings['overrideStartRelative']);
552
                if ($overrideStartDateRelative === '') {
553
                    $overrideStartDateRelative = 'now';
554
                }
555
                try {
556
                    $relativeDate = new \DateTime($overrideStartDateRelative);
557
                } catch (\Exception $e) {
558
                    $relativeDate = new \DateTime();
559
                }
560
                $overrideStartDate = $relativeDate->getTimestamp();
561
                $overrideEndDate = 0;
562
                $overrideEndDateRelative = trim($this->settings['overrideEndRelative']);
563
                if ($overrideStartDateRelative !== '') {
564
                    try {
565
                        $relativeDate->modify($overrideEndDateRelative);
566
                        $overrideEndDate = $relativeDate->getTimestamp();
567
                    } catch (\Exception $e) {
568
                        // do nothing $overrideEndDate is 0
569
                    }
570
                }
571
            } else {
572
                $overrideStartDate = (int) $this->settings['overrideStartdate'];
573
                $overrideEndDate = (int) $this->settings['overrideEnddate'];
574
            }
575
            $indices = $this->indexRepository->findList(
576
                (int) $this->settings['limit'],
577
                $this->settings['listStartTime'],
578
                (int) $this->settings['listStartTimeOffsetHours'],
579
                $overrideStartDate,
580
                $overrideEndDate
581
            );
582
        }
583
584
        // use this variable in your extension to add more custom variables
585
        $variables = [
586
            'extended' => [
587
                'indices' => $indices,
588
                'searchMode' => $searchMode,
589
                'parameters' => [
590
                    'startDate' => $startDate,
591
                    'endDate' => $endDate,
592
                    'customSearch' => $customSearch,
593
                    'year' => $year,
594
                    'month' => $month,
595
                    'day' => $day,
596
                    'week' => $week,
597
                ],
598
            ],
599
        ];
600
        $variables['settings'] = $this->settings;
601
602
        $dispatcher = $this->objectManager->get(Dispatcher::class);
603
        $variables = $dispatcher->dispatch(__CLASS__, __FUNCTION__, $variables);
604
605
        return $variables['extended'];
606
    }
607
608
    /**
609
     * Get the allowed actions.
610
     *
611
     * @return array
612
     */
613
    protected function getAllowedActions(): array
614
    {
615
        $configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
616
        $allowedActions = [];
617
        foreach ($configuration['controllerConfiguration'] as $controllerName => $controllerActions) {
618
            $allowedActions[$controllerName] = $controllerActions['actions'];
619
        }
620
621
        return \is_array($allowedActions['Calendar']) ? $allowedActions['Calendar'] : [];
622
    }
623
624
    /**
625
     * Get the current configurations.
626
     *
627
     * @return array
628
     */
629
    protected function getCurrentConfigurations()
630
    {
631
        $configurations = GeneralUtility::trimExplode(',', $this->settings['configuration'], true);
632
        $return = [];
633
        foreach (Register::getRegister() as $key => $configuration) {
634
            if (\in_array($key, $configurations, true)) {
635
                $return[] = $configuration;
636
            }
637
        }
638
639
        return $return;
640
    }
641
642
    /**
643
     * A redirect that have a slot included.
644
     *
645
     * @param string $signalClassName name of the signal class: __CLASS__
646
     * @param string $signalName      name of the signal: __FUNCTION__
647
     * @param array  $variables       optional: if not set use the defaults
648
     */
649
    protected function slottedRedirect($signalClassName, $signalName, $variables = null)
650
    {
651
        // set default variables for the redirect
652
        if (null === $variables) {
653
            $variables['extended'] = [
654
                'actionName' => 'list',
655
                'controllerName' => null,
656
                'extensionName' => null,
657
                'arguments' => [],
658
                'pageUid' => $this->settings['listPid'],
659
                'delay' => 0,
660
                'statusCode' => 301,
661
            ];
662
            $variables['extended']['pluginHmac'] = $this->calculatePluginHmac();
663
            $variables['settings'] = $this->settings;
664
        }
665
666
        $dispatcher = $this->objectManager->get(Dispatcher::class);
667
        $variables = $dispatcher->dispatch($signalClassName, $signalName, $variables);
668
669
        $this->redirect(
670
            $variables['extended']['actionName'],
671
            $variables['extended']['controllerName'],
672
            $variables['extended']['extensionName'],
673
            $variables['extended']['arguments'],
674
            $variables['extended']['pageUid'],
675
            $variables['extended']['delay'],
676
            $variables['extended']['statusCode']
677
        );
678
    }
679
}
680