3737use TYPO3 \CMS \ContentBlocks \Registry \LanguageFileRegistry ;
3838use TYPO3 \CMS \ContentBlocks \Schema \SimpleTcaSchemaFactory ;
3939use TYPO3 \CMS \ContentBlocks \Service \SystemExtensionAvailability ;
40+ use TYPO3 \CMS \ContentBlocks \Validation \PageTypeNameValidator ;
4041use TYPO3 \CMS \Core \Configuration \Event \BeforeTcaOverridesEvent ;
4142use TYPO3 \CMS \Core \Utility \ArrayUtility ;
4243use TYPO3 \CMS \Core \Utility \ExtensionManagementUtility ;
@@ -165,7 +166,9 @@ protected function generateTableTca(TableDefinition $tableDefinition, array $bas
165166 }
166167 $ tca ['types ' ][$ typeDefinition ->getTypeName ()] = $ this ->processTypeDefinition ($ typeDefinition , $ tableDefinition );
167168 if ($ tableDefinition ->hasTypeField ()) {
168- $ tca ['ctrl ' ]['typeicon_classes ' ][$ typeDefinition ->getTypeName ()] = $ typeDefinition ->getTypeIcon ()->iconIdentifier ;
169+ if ($ typeDefinition ->getTypeIcon ()->initialized ) {
170+ $ tca ['ctrl ' ]['typeicon_classes ' ][$ typeDefinition ->getTypeName ()] = $ typeDefinition ->getTypeIcon ()->iconIdentifier ;
171+ }
169172 if ($ typeDefinition instanceof PageTypeDefinition) {
170173 if ($ typeDefinition ->getPageIconSet ()->iconHideInMenu ->initialized ) {
171174 $ tca ['ctrl ' ]['typeicon_classes ' ][$ typeDefinition ->getTypeName () . '-hideinmenu ' ] = $ typeDefinition ->getPageIconSet ()->iconHideInMenu ->iconIdentifier ;
@@ -176,7 +179,7 @@ protected function generateTableTca(TableDefinition $tableDefinition, array $bas
176179 }
177180 }
178181 if ($ tableDefinition ->contentType === ContentType::RECORD_TYPE ) {
179- if ($ isNewTable || !isset ($ baseTca [$ tableDefinition ->table ]['ctrl ' ]['typeicon_classes ' ]['default ' ])) {
182+ if ($ typeDefinition -> getTypeIcon ()-> initialized && ( $ isNewTable || !isset ($ baseTca [$ tableDefinition ->table ]['ctrl ' ]['typeicon_classes ' ]['default ' ]) )) {
180183 $ tca ['ctrl ' ]['typeicon_classes ' ]['default ' ] ??= $ typeDefinition ->getTypeIcon ()->iconIdentifier ;
181184 }
182185 if ($ tableDefinition ->hasTypeField ()) {
@@ -262,6 +265,10 @@ protected function fillTypeFieldSelectItems(): void
262265 continue ;
263266 }
264267 foreach ($ tableDefinition ->contentTypeDefinitionCollection as $ typeDefinition ) {
268+ $ typeName = $ typeDefinition ->getTypeName ();
269+ if ($ tableDefinition ->contentType === ContentType::PAGE_TYPE && PageTypeNameValidator::isExistingPageType ($ typeName )) {
270+ continue ;
271+ }
265272 $ languagePathTitle = $ typeDefinition ->getLanguagePathTitle ();
266273 if ($ this ->languageFileRegistry ->isset ($ typeDefinition ->getName (), $ languagePathTitle )) {
267274 $ label = $ languagePathTitle ;
@@ -274,13 +281,14 @@ protected function fillTypeFieldSelectItems(): void
274281 } else {
275282 $ description = $ typeDefinition ->getDescription ();
276283 }
284+ $ icon = $ typeDefinition ->getTypeIcon ();
277285 ExtensionManagementUtility::addTcaSelectItem (
278286 $ typeDefinition ->getTable (),
279287 $ tableDefinition ->typeField ,
280288 [
281289 'label ' => $ label ,
282- 'value ' => $ typeDefinition -> getTypeName () ,
283- 'icon ' => $ typeDefinition -> getTypeIcon () ->iconIdentifier ,
290+ 'value ' => $ typeName ,
291+ 'icon ' => $ icon -> initialized ? $ icon ->iconIdentifier : null ,
284292 'group ' => $ typeDefinition ->getGroup (),
285293 'description ' => $ description ,
286294 ]
0 commit comments