Completed
Push — development ( 640c04...189908 )
by Torben
09:05 queued 03:50
created

injectRegistrationRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 1
cts 1
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 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\Domain\Model\Dto\UserRegistrationDemand;
18
use DERHANSEN\SfEventMgt\Utility\Page;
19
20
/**
21
 * UserRegistrationController
22
 *
23
 * @author Torben Hansen <[email protected]>
24
 */
25
class UserRegistrationController extends AbstractController
26
{
27
    /**
28
     * Creates an user registration demand object with the given settings
29
     *
30
     * @param array $settings The settings
31
     *
32
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Dto\UserRegistrationDemand
33
     */
34
    public function createUserRegistrationDemandObjectFromSettings(array $settings)
35
    {
36
        /** @var \DERHANSEN\SfEventMgt\Domain\Model\Dto\UserRegistrationDemand $demand */
37
        $demand = $this->objectManager->get(UserRegistrationDemand::class);
38
        $demand->setDisplayMode($settings['userRegistration']['displayMode']);
39
        $demand->setStoragePage(Page::extendPidListByChildren(
40
            $settings['userRegistration']['storagePage'],
41
            $settings['userRegistration']['recursive']
42
        ));
43
        $demand->setOrderField($settings['userRegistration']['orderField']);
44
        $demand->setOrderDirection($settings['userRegistration']['orderDirection']);
45
        return $demand;
46
    }
47 1
48
    /**
49
     * Shows a list of all registration of the current frontend user
50 1
     *
51 1
     * @return void
52 1
     */
53 1
    public function listAction()
54 1
    {
55 1
        $demand = $this->createUserRegistrationDemandObjectFromSettings($this->settings);
56 1
        $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...
57 1
        $registrations = $this->registrationRepository->findRegistrationsByUserRegistrationDemand($demand);
58 1
        $this->view->assign('registrations', $registrations);
59
    }
60
}
61