@@ -37,14 +37,17 @@ public function __construct(
37
37
protected TableDefinitionCollection $ tableDefinitionCollection ,
38
38
protected PreviewIconResolver $ previewIconResolver ,
39
39
protected ContentBlockBuilder $ contentBlockBuilder ,
40
+ /**
41
+ * @var array{content?: string, backend?: string}
42
+ */
40
43
protected array $ maskExtensionConfiguration ,
41
44
) {
42
45
parent ::__construct ();
43
46
}
44
47
45
48
public function execute (InputInterface $ input , OutputInterface $ output ): int
46
49
{
47
- $ table = ContentType:: CONTENT_ELEMENT -> getTable () ;
50
+ $ table = ' tt_content ' ;
48
51
$ targetExtension = $ this ->extractExtensionFromMaskConfiguration ();
49
52
if (!$ this ->tableDefinitionCollection ->hasTable ($ table )) {
50
53
$ output ->writeln ('No Mask elements found. ' );
@@ -55,7 +58,9 @@ public function execute(InputInterface $input, OutputInterface $output): int
55
58
if ($ element ->hidden ) {
56
59
continue ;
57
60
}
58
- $ fieldArray = $ this ->traverseMaskColumnsRecursive ($ element , $ element ->columns , $ contentElementTableDefinition );
61
+ /** @var string[] $columns */
62
+ $ columns = $ element ->columns ;
63
+ $ fieldArray = $ this ->traverseMaskColumnsRecursive ($ element , $ columns , $ contentElementTableDefinition );
59
64
$ contentBlockName = str_replace ('_ ' , '- ' , $ element ->key );
60
65
$ name = 'mask/ ' . $ contentBlockName ;
61
66
$ path = 'EXT: ' . $ targetExtension . '/ ' . ContentBlockPathUtility::getRelativeContentElementsPath ();
@@ -102,7 +107,7 @@ protected function extractExtensionFromMaskConfiguration(): string
102
107
return $ extensionKey ;
103
108
}
104
109
105
- protected function copyFrontendTemplate (string $ contentElementKey , $ targetExtPath ): void
110
+ protected function copyFrontendTemplate (string $ contentElementKey , string $ targetExtPath ): void
106
111
{
107
112
$ absolutePath = GeneralUtility::getFileAbsFileName ($ targetExtPath );
108
113
$ absoluteTemplatePath = $ absolutePath . '/ ' . ContentBlockPathUtility::getFrontendTemplatePath ();
@@ -112,22 +117,23 @@ protected function copyFrontendTemplate(string $contentElementKey, $targetExtPat
112
117
}
113
118
}
114
119
115
- protected function copyPreviewTemplate (string $ contentElementKey , $ targetExtPath ): void
120
+ protected function copyPreviewTemplate (string $ contentElementKey , string $ targetExtPath ): void
116
121
{
117
122
$ absolutePath = GeneralUtility::getFileAbsFileName ($ targetExtPath );
118
123
$ absoluteTemplatePath = $ absolutePath . '/ ' . ContentBlockPathUtility::getBackendPreviewPath ();
124
+ $ backendPreviewTemplatePath = (string )($ this ->maskExtensionConfiguration ['backend ' ] ?? '' );
119
125
$ maskPreviewTemplate = TemplatePathUtility::getTemplatePath (
120
126
$ this ->maskExtensionConfiguration ,
121
127
$ contentElementKey ,
122
128
false ,
123
- GeneralUtility::getFileAbsFileName ($ this -> maskExtensionConfiguration [ ' backend ' ] ?? '' )
129
+ GeneralUtility::getFileAbsFileName ($ backendPreviewTemplatePath )
124
130
);
125
131
if (file_exists ($ maskPreviewTemplate )) {
126
132
copy ($ maskPreviewTemplate , $ absoluteTemplatePath );
127
133
}
128
134
}
129
135
130
- protected function copyIcon (string $ contentElementKey , $ targetExtPath ): void
136
+ protected function copyIcon (string $ contentElementKey , string $ targetExtPath ): void
131
137
{
132
138
$ absolutePath = GeneralUtility::getFileAbsFileName ($ targetExtPath );
133
139
$ absoluteIconPath = $ absolutePath . '/ ' . ContentBlockPathUtility::getIconPathWithoutFileExtension ();
@@ -144,12 +150,20 @@ protected function copyIcon(string $contentElementKey, $targetExtPath): void
144
150
}
145
151
}
146
152
153
+ /**
154
+ * @param string[] $columns
155
+ * @return array<array<string, mixed>>
156
+ */
147
157
protected function traverseMaskColumnsRecursive (ElementDefinition $ element , array $ columns , TableDefinition $ tableDefinition ): array
148
158
{
149
159
$ fieldArray = [];
160
+ if ($ tableDefinition ->tca === null ) {
161
+ return $ fieldArray ;
162
+ }
150
163
foreach ($ columns as $ fieldKey ) {
151
164
$ field = [];
152
165
$ tcaFieldDefinition = $ tableDefinition ->tca ->getField ($ fieldKey );
166
+ /** @var array<string, mixed> $tca */
153
167
$ tca = $ tcaFieldDefinition ->realTca ['config ' ] ?? [];
154
168
unset($ tca ['type ' ]);
155
169
try {
@@ -194,6 +208,7 @@ protected function traverseMaskColumnsRecursive(ElementDefinition $element, arra
194
208
$ columnsOverrides = [];
195
209
if ($ element ->hasColumnsOverride ($ fieldKey )) {
196
210
$ columnsOverrideTcaDefinition = $ element ->getColumnsOverride ($ fieldKey );
211
+ /** @var array<string, mixed> $columnsOverrides */
197
212
$ columnsOverrides = $ columnsOverrideTcaDefinition ->realTca ['config ' ] ?? [];
198
213
}
199
214
$ field = array_merge ($ field , $ tca , $ columnsOverrides );
@@ -227,7 +242,9 @@ protected function traverseMaskColumnsRecursive(ElementDefinition $element, arra
227
242
}
228
243
if ($ fieldType ->isParentField ()) {
229
244
$ inlineFields = $ this ->tableDefinitionCollection ->loadInlineFields ($ fieldKey , $ element ->key , $ element );
230
- $ inlineColumns = array_map (fn (array $ tcaField ) => $ tcaField ['fullKey ' ], $ inlineFields ->toArray ());
245
+ /** @var array<array{fullKey: string}> $array */
246
+ $ array = $ inlineFields ->toArray ();
247
+ $ inlineColumns = array_map (fn (array $ tcaField ): string => $ tcaField ['fullKey ' ], $ array );
231
248
$ foreignTableDefinition = $ tableDefinition ;
232
249
if ($ fieldType === FieldType::INLINE ) {
233
250
unset($ field ['foreign_table ' ]);
0 commit comments