Completed
Push — middleware ( 1eef6b )
by Romain
02:33
created

FormController::processFormAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/*
3
 * 2017 Romain CANON <[email protected]>
4
 *
5
 * This file is part of the TYPO3 Formz project.
6
 * It is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License, either
8
 * version 3 of the License, or any later version.
9
 *
10
 * For the full copyright and license information, see:
11
 * http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Romm\Formz\Controller;
15
16
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
17
use TYPO3\CMS\Extbase\Security\Cryptography\HashService;
18
19
class FormController extends ActionController
20
{
21
    /**
22
     * @var FormzControllerContext
23
     */
24
    protected $formzControllerContext;
25
26
    /**
27
     * @var HashService
28
     */
29
    protected $hashService;
30
31
    /**
32
     * Main action used to dispatch the request properly, depending on Formz
33
     * configuration.
34
     */
35
    public function processFormAction()
36
    {
37
        $this->formzControllerContext->setDispatched(true);
38
39
        $this->forward(
40
            $this->formzControllerContext->getActionName(),
41
            $this->formzControllerContext->getControllerName(),
42
            $this->formzControllerContext->getExtensionName()
43
        );
44
    }
45
46
    /**
47
     * @todo
48
     *
49
     * @return array
50
     */
51
    protected function getRequestData()
52
    {
53
        $requestData = [];
54
55
        if ($this->request->hasArgument('formz')) {
56
            $requestData = $this->request->getArgument('formz');
57
            $requestData = $this->hashService->validateAndStripHmac($requestData);
58
            $requestData = unserialize(base64_decode($requestData));
59
        }
60
61
        return $requestData;
62
    }
63
64
    /**
65
     * @param FormzControllerContext $formzControllerContext
66
     */
67
    public function injectFormzControllerContext(FormzControllerContext $formzControllerContext)
68
    {
69
        $this->formzControllerContext = $formzControllerContext;
70
    }
71
72
    /**
73
     * @param HashService $hashService
74
     */
75
    public function injectHashService(HashService $hashService)
76
    {
77
        $this->hashService = $hashService;
78
    }
79
}
80