39
39
*/
40
40
class FormFrontendController extends ActionController
41
41
{
42
- /**
43
- * @var \TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface
44
- */
45
- protected $ formPersistenceManager ;
46
-
47
- /**
48
- * @internal
49
- */
50
- public function injectFormPersistenceManager (FormPersistenceManagerInterface $ formPersistenceManager )
51
- {
52
- $ this ->formPersistenceManager = $ formPersistenceManager ;
53
- }
42
+ public function __construct (
43
+ protected readonly ConfigurationService $ configurationService ,
44
+ protected readonly FormPersistenceManagerInterface $ formPersistenceManager ,
45
+ protected readonly FlexFormService $ flexFormService ,
46
+ protected readonly FlexFormTools $ flexFormTools ,
47
+ ) {}
54
48
55
49
/**
56
50
* Take the form which should be rendered from the plugin settings
@@ -72,7 +66,6 @@ public function renderAction(): ResponseInterface
72
66
$ formDefinition ['identifier ' ] .= '- ' . ($ this ->request ->getAttribute ('currentContentObject ' )?->data['uid ' ] ?? '' );
73
67
}
74
68
$ this ->view ->assign ('formConfiguration ' , $ formDefinition );
75
-
76
69
return $ this ->htmlResponse ();
77
70
}
78
71
@@ -94,22 +87,16 @@ public function performAction(): ResponseInterface
94
87
protected function overrideByFlexFormSettings (array $ formDefinition ): array
95
88
{
96
89
$ flexFormData = GeneralUtility::xml2array ($ this ->request ->getAttribute ('currentContentObject ' )?->data['pi_flexform ' ] ?? '' );
97
-
98
90
if (!is_array ($ flexFormData )) {
99
91
return $ formDefinition ;
100
92
}
101
-
102
93
if (isset ($ formDefinition ['finishers ' ])) {
103
94
$ prototypeName = $ formDefinition ['prototypeName ' ] ?? 'standard ' ;
104
- $ configurationService = GeneralUtility::makeInstance (ConfigurationService::class);
105
- $ prototypeConfiguration = $ configurationService ->getPrototypeConfiguration ($ prototypeName );
106
-
95
+ $ prototypeConfiguration = $ this ->configurationService ->getPrototypeConfiguration ($ prototypeName );
107
96
foreach ($ formDefinition ['finishers ' ] as $ index => $ formFinisherDefinition ) {
108
97
$ finisherIdentifier = $ formFinisherDefinition ['identifier ' ];
109
-
110
98
$ sheetIdentifier = $ this ->getFlexformSheetIdentifier ($ formDefinition , $ prototypeName , $ finisherIdentifier );
111
99
$ flexFormSheetSettings = $ this ->getFlexFormSettingsFromSheet ($ flexFormData , $ sheetIdentifier );
112
-
113
100
if (($ this ->settings ['overrideFinishers ' ] ?? false ) && isset ($ flexFormSheetSettings ['finishers ' ][$ finisherIdentifier ])) {
114
101
$ prototypeFinisherDefinition = $ prototypeConfiguration ['finishersDefinition ' ][$ finisherIdentifier ] ?? [];
115
102
$ converterDto = GeneralUtility::makeInstance (
@@ -119,7 +106,6 @@ protected function overrideByFlexFormSettings(array $formDefinition): array
119
106
$ finisherIdentifier ,
120
107
$ flexFormSheetSettings
121
108
);
122
-
123
109
// Iterate over all `prototypes.<prototypeName>.finishersDefinition.<finisherIdentifier>.FormEngine.elements` values
124
110
GeneralUtility::makeInstance (ArrayProcessor::class, $ prototypeFinisherDefinition ['FormEngine ' ]['elements ' ])->forEach (
125
111
GeneralUtility::makeInstance (
@@ -129,19 +115,15 @@ protected function overrideByFlexFormSettings(array $formDefinition): array
129
115
GeneralUtility::makeInstance (FinisherOptionsFlexFormOverridesConverter::class, $ converterDto )
130
116
)
131
117
);
132
-
133
118
$ formDefinition ['finishers ' ][$ index ] = $ converterDto ->getFinisherDefinition ();
134
119
}
135
120
}
136
121
}
137
122
return $ formDefinition ;
138
123
}
139
124
140
- protected function getFlexformSheetIdentifier (
141
- array $ formDefinition ,
142
- string $ prototypeName ,
143
- string $ finisherIdentifier
144
- ): string {
125
+ protected function getFlexformSheetIdentifier (array $ formDefinition , string $ prototypeName , string $ finisherIdentifier ): string
126
+ {
145
127
return md5 (
146
128
implode ('' , [
147
129
$ formDefinition ['persistenceIdentifier ' ],
@@ -152,10 +134,8 @@ protected function getFlexformSheetIdentifier(
152
134
);
153
135
}
154
136
155
- protected function getFlexFormSettingsFromSheet (
156
- array $ flexForm ,
157
- string $ sheetIdentifier
158
- ): array {
137
+ protected function getFlexFormSettingsFromSheet (array $ flexForm , string $ sheetIdentifier ): array
138
+ {
159
139
$ sheetData = [];
160
140
$ sheetData ['data ' ] = array_filter (
161
141
$ flexForm ['data ' ] ?? [],
@@ -164,15 +144,10 @@ static function ($key) use ($sheetIdentifier) {
164
144
},
165
145
ARRAY_FILTER_USE_KEY
166
146
);
167
-
168
147
if (empty ($ sheetData ['data ' ])) {
169
148
return [];
170
149
}
171
-
172
- $ flexFormService = GeneralUtility::makeInstance (FlexFormService::class);
173
- $ flexFormTools = GeneralUtility::makeInstance (FlexFormTools::class);
174
-
175
- $ sheetDataXml = $ flexFormTools ->flexArray2Xml ($ sheetData );
176
- return $ flexFormService ->convertFlexFormContentToArray ($ sheetDataXml )['settings ' ] ?? [];
150
+ $ sheetDataXml = $ this ->flexFormTools ->flexArray2Xml ($ sheetData );
151
+ return $ this ->flexFormService ->convertFlexFormContentToArray ($ sheetDataXml )['settings ' ] ?? [];
177
152
}
178
153
}
0 commit comments