Completed
Push — development ( deb2fc...28a639 )
by Torben
04:28 queued 25s
created

UserRegistrationController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 4
dl 0
loc 71
ccs 16
cts 16
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A injectRegistrationRepository() 0 5 1
A injectRegistrationService() 0 4 1
A createUserRegistrationDemandObjectFromSettings() 0 13 1
A listAction() 0 7 1
1
<?php
2
namespace DERHANSEN\SfEventMgt\Controller;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use DERHANSEN\SfEventMgt\Utility\Page;
18
19
/**
20
 * UserRegistrationController
21
 *
22
 * @author Torben Hansen <[email protected]>
23
 */
24
class UserRegistrationController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
25
{
26
    /**
27
     * RegistrationService
28
     *
29
     * @var \DERHANSEN\SfEventMgt\Service\RegistrationService
30
     */
31
    protected $registrationService;
32
33
    /**
34
     * RegistrationRespository
35
     *
36
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository
37
     */
38
    protected $registrationRepository;
39
40
    /**
41
     * DI for $registrationRepository
42
     *
43
     * @param \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository $registrationRepository
44
     */
45
    public function injectRegistrationRepository(
46
        \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository $registrationRepository
47 1
    ) {
48
        $this->registrationRepository = $registrationRepository;
49
    }
50 1
51 1
    /**
52 1
     * DI for $registrationService
53 1
     *
54 1
     * @param \DERHANSEN\SfEventMgt\Service\RegistrationService $registrationService
55 1
     */
56 1
    public function injectRegistrationService(\DERHANSEN\SfEventMgt\Service\RegistrationService $registrationService)
57 1
    {
58 1
        $this->registrationService = $registrationService;
59
    }
60
61
    /**
62
     * Creates an user registration demand object with the given settings
63
     *
64
     * @param array $settings The settings
65
     *
66 1
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Dto\UserRegistrationDemand
67
     */
68 1
    public function createUserRegistrationDemandObjectFromSettings(array $settings)
69 1
    {
70 1
        /** @var \DERHANSEN\SfEventMgt\Domain\Model\Dto\UserRegistrationDemand $demand */
71 1
        $demand = $this->objectManager->get('DERHANSEN\\SfEventMgt\\Domain\\Model\\Dto\\UserRegistrationDemand');
72 1
        $demand->setDisplayMode($settings['userRegistration']['displayMode']);
73
        $demand->setStoragePage(Page::extendPidListByChildren(
74
            $settings['userRegistration']['storagePage'],
75
            $settings['userRegistration']['recursive']
76
        ));
77
        $demand->setOrderField($settings['userRegistration']['orderField']);
78
        $demand->setOrderDirection($settings['userRegistration']['orderDirection']);
79
        return $demand;
80
    }
81
82
    /**
83
     * Shows a list of all registration of the current frontend user
84
     *
85
     * @return void
86
     */
87
    public function listAction()
88
    {
89
        $demand = $this->createUserRegistrationDemandObjectFromSettings($this->settings);
90
        $demand->setUser($this->registrationService->getCurrentFeUserObject());
0 ignored issues
show
Documentation introduced by
$this->registrationServi...etCurrentFeUserObject() is of type object|null, but the function expects a object<TYPO3\CMS\Extbase...ain\Model\FrontendUser>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
91
        $registrations = $this->registrationRepository->findRegistrationsByUserRegistrationDemand($demand);
92
        $this->view->assign('registrations', $registrations);
93
    }
94
}
95