1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the TYPO3 CMS project. |
7
|
|
|
* |
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
10
|
|
|
* of the License, or any later version. |
11
|
|
|
* |
12
|
|
|
* For the full copyright and license information, please read the |
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
14
|
|
|
* |
15
|
|
|
* The TYPO3 project - inspiring people to share! |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
/* |
19
|
|
|
* Inspired by and partially taken from the Neos.Form package (www.neos.io) |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace TYPO3\CMS\Form\Domain\Finishers; |
23
|
|
|
|
24
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
25
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext; |
26
|
|
|
use TYPO3\CMS\Extbase\Mvc\Request; |
27
|
|
|
use TYPO3\CMS\Form\Domain\Runtime\FormRuntime; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The context that is passed to each finisher when executed. |
31
|
|
|
* It acts like an EventObject that is able to stop propagation. |
32
|
|
|
* |
33
|
|
|
* Scope: frontend |
34
|
|
|
* **This class is NOT meant to be sub classed by developers.** |
35
|
|
|
* @internal |
36
|
|
|
*/ |
37
|
|
|
class FinisherContext |
38
|
|
|
{ |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* If TRUE further finishers won't be invoked |
42
|
|
|
* |
43
|
|
|
* @var bool |
44
|
|
|
*/ |
45
|
|
|
protected $cancelled = false; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* A reference to the Form Runtime the finisher belongs to |
49
|
|
|
*/ |
50
|
|
|
protected FormRuntime $formRuntime; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* The assigned controller context which might be needed by the finisher. |
54
|
|
|
*/ |
55
|
|
|
protected ControllerContext $controllerContext; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* The assigned controller context which might be needed by the finisher. |
59
|
|
|
*/ |
60
|
|
|
protected FinisherVariableProvider $finisherVariableProvider; |
61
|
|
|
|
62
|
|
|
private Request $request; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param FormRuntime $formRuntime |
66
|
|
|
* @param ControllerContext $controllerContext |
67
|
|
|
* @param Request $request |
68
|
|
|
* @internal |
69
|
|
|
*/ |
70
|
|
|
public function __construct(FormRuntime $formRuntime, ControllerContext $controllerContext, Request $request) |
71
|
|
|
{ |
72
|
|
|
$this->formRuntime = $formRuntime; |
73
|
|
|
$this->controllerContext = $controllerContext; |
74
|
|
|
$this->request = $request; |
75
|
|
|
$this->finisherVariableProvider = GeneralUtility::makeInstance(FinisherVariableProvider::class); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Cancels the finisher invocation after the current finisher |
80
|
|
|
*/ |
81
|
|
|
public function cancel() |
82
|
|
|
{ |
83
|
|
|
$this->cancelled = true; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* TRUE if no further finishers should be invoked. Defaults to FALSE |
88
|
|
|
* |
89
|
|
|
* @return bool |
90
|
|
|
* @internal |
91
|
|
|
*/ |
92
|
|
|
public function isCancelled(): bool |
93
|
|
|
{ |
94
|
|
|
return $this->cancelled; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* The Form Runtime that is associated with the current finisher |
99
|
|
|
* |
100
|
|
|
* @return FormRuntime |
101
|
|
|
*/ |
102
|
|
|
public function getFormRuntime(): FormRuntime |
103
|
|
|
{ |
104
|
|
|
return $this->formRuntime; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* The values of the submitted form (after validation and property mapping) |
109
|
|
|
* |
110
|
|
|
* @return array |
111
|
|
|
*/ |
112
|
|
|
public function getFormValues(): array |
113
|
|
|
{ |
114
|
|
|
return $this->formRuntime->getFormState()->getFormValues(); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return ControllerContext |
119
|
|
|
* @deprecated since v11, will be removed in v12 |
120
|
|
|
*/ |
121
|
|
|
public function getControllerContext(): ControllerContext |
122
|
|
|
{ |
123
|
|
|
return $this->controllerContext; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return FinisherVariableProvider |
128
|
|
|
*/ |
129
|
|
|
public function getFinisherVariableProvider(): FinisherVariableProvider |
130
|
|
|
{ |
131
|
|
|
return $this->finisherVariableProvider; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function getRequest(): Request |
135
|
|
|
{ |
136
|
|
|
return $this->request; |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|