Completed
Push — master ( ec29fe...2e5711 )
by Torben
09:02 queued 07:11
created

UserRegistrationController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
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
     * @inject
31
     */
32
    protected $registrationService;
33
34
    /**
35
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository
36
     * @inject
37
     */
38
    protected $registrationRepository;
39
40
    /**
41
     * Creates an user registration demand object with the given settings
42
     *
43
     * @param array $settings The settings
44
     *
45
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Dto\UserRegistrationDemand
46
     */
47 1
    public function createUserRegistrationDemandObjectFromSettings(array $settings)
48
    {
49
        /** @var \DERHANSEN\SfEventMgt\Domain\Model\Dto\UserRegistrationDemand $demand */
50 1
        $demand = $this->objectManager->get('DERHANSEN\\SfEventMgt\\Domain\\Model\\Dto\\UserRegistrationDemand');
51 1
        $demand->setDisplayMode($settings['userRegistration']['displayMode']);
52 1
        $demand->setStoragePage(Page::extendPidListByChildren(
53 1
            $settings['userRegistration']['storagePage'],
54 1
            $settings['userRegistration']['recursive']
55 1
        ));
56 1
        $demand->setOrderField($settings['userRegistration']['orderField']);
57 1
        $demand->setOrderDirection($settings['userRegistration']['orderDirection']);
58 1
        return $demand;
59
    }
60
61
    /**
62
     * Shows a list of all registration of the current frontend user
63
     *
64
     * @return void
65
     */
66 1
    public function listAction()
67
    {
68 1
        $demand = $this->createUserRegistrationDemandObjectFromSettings($this->settings);
69 1
        $demand->setUser($this->registrationService->getCurrentFeUserObject());
70 1
        $registrations = $this->registrationRepository->findRegistrationsByUserRegistrationDemand($demand);
71 1
        $this->view->assign('registrations', $registrations);
72 1
    }
73
}
74